Hi,
I've had problems storing a 'javax.xml.transform.Templates' object
(i.e. an 'org.apache.xalan.templates.StylesheetRoot') out in my
database. Serialization doesn't work as expected, at least for me (W2K,
JDK 1.3, 1.3.1, 1.4b, Xerces 1.4, Xalan 2.1).
Serializing a stylesheet, storing it, reconstructing the template and
then performing a transformation results in a rather lengthly stack
trace.
I've tracked the error down to
'org.apache.xpath.axes.UnionPathIterator'. Throws a
'java.lang.NullPointerException' at line 228. Seems to me that the
object pool (m_pool) is not re-initialized during deserialization.
I am sure that during the deserialization of an object no constructors
are called. Static fields or static initializers are initialized. But
could it be that normal fields are not automatically initialized during
deserialization?
Because I need in my app a working serialization support, I've added
the apprioate deserialization function (see below) to
'UnionPathIterator.java'. Making the member field static would achieve
the same result, but may produce side effects. Feel free to test.
-----code snippet -------------------
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
// Make sure pool is initialized
m_pool = new ObjectPool(this.getClass());
}
-----code snippet -------------------
I've attached a class to test the behaviour I've just described. Unzip
all three classes in a directory, add your parser and processor to the
classpath. Executing 'java SerializationTest' should produce the stack
dump. If not, feel free to blame me!
Cheers,
Marco
serializationtest.zip