  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | NPE on Serialization | NPE on Serialization 2007-07-10 - By Jan Kriesten
Back
Hi,
I get the following NPE on serializing JDOM 1.0:
---8<--- 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]] java.lang.NullPointerException at org.jdom.filter.ElementFilter.writeObject(ElementFilter.java:167) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ---8<---
In ElementFilter.java:167 there's no check whether or not 'namespace' is actually set.
Changing writeObject() to
---8<--- private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
// We use writeObject() and not writeUTF() to minimize space // This allows for writing pointers to already written strings if( namespace!=null ) { out.writeObject(namespace.getPrefix()); out.writeObject(namespace.getURI()); } } ---8<---
solves the problem. Does this have any side-effects?
Best regards, --- Jan.
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |