http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2633 *** shadow/2633 Sun Jul 15 11:24:48 2001 --- shadow/2633.tmp.25626 Sun Jul 15 11:24:48 2001 *************** *** 0 **** --- 1,65 ---- + +============================================================================+ + | Broken serialization support in XALAN 2.1 (UnionPathIterator) | + +----------------------------------------------------------------------------+ + | Bug #: 2633 Product: XalanJ2 | + | Status: NEW Version: 2.1.0 | + | Resolution: Platform: PC | + | Severity: Normal OS/Version: Windows NT/2K | + | Priority: Other Component: org.apache.xpath | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + 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 (member var 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 (re-)initialized during + deserialization? + + Because I need in my app a working serialization support, I've added + a deserialization function (see below) to 'UnionPathIterator.java'. + Making the member field static should achieve the same result, but may + produce side effects. Feel free to test. + + The following code goes in 'UnionPathIterator.java': + + -----code snippet ------------------- + + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + + // Make sure pool is initialized during deserialization + m_pool = new ObjectPool(this.getClass()); + } + + -----code snippet ------------------- + + + + I've tried mailing a zip with test files to the xalan-dev account, but the mail + was rejected. Fell free to contact me if you want further information. + + + Cheers, + + Marco
