[jdom-interest] NPE on Serialization

Jan Kriesten jan.kriesten at renitence.de
Tue Jul 10 02:27:10 PDT 2007


I get the following NPE on serializing JDOM 1.0:

11:17:15.220 ERROR [org.apache.wicket.util.lang.Objects          ] - Error
serializing object class de.silberlicht.wsl.test.HelloWor
ld [object=[Page class = de.silberlicht.wsl.test.HelloWorld, id = 3, version = 0]]
        at org.jdom.filter.ElementFilter.writeObject(ElementFilter.java:167)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

In ElementFilter.java:167 there's no check whether or not 'namespace' is
actually set.

Changing writeObject() to

    private void writeObject(ObjectOutputStream out) throws IOException {


        // We use writeObject() and not writeUTF() to minimize space
        // This allows for writing pointers to already written strings
        if( namespace!=null )

solves the problem. Does this have any side-effects?

Best regards, --- Jan.

More information about the jdom-interest mailing list