After a servlet that I wrote using Xerces has been running for an
undetermined amount of time (I'm not sure what conditions trigger this), I
get the following exception that comes up *every* time I run my servlet
from then on, until I restart the server:

- <exception lang="java">
  <type>java.lang.NullPointerException</type> 
  <message /> 
- <stacktrace>
  <p>java.lang.NullPointerException</p> 
  <p>at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(DeferredDocumentImpl.java:1218)</p>
 
  <p>at
org.apache.xerces.dom.DocumentImpl.getDocumentElement(DocumentImpl.java:456)</p>
 
  <p>at net.press.pa.storymanager.Frontend.execute(Frontend.java:63)</p> 
  <p>at
net.press.pa.storymanager.servlets.SMInterface.doGet(SMInterface.java:208)</p> 
  <p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)</p> 
  <p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)</p> 
  <p>at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)</p> 
  <p>at org.apache.jserv.JServConnection.run(JServConnection.java:188)</p> 
  <p>at java.lang.Thread.run(Thread.java:479)</p> 
  </stacktrace>
  </exception>

(This is an XML pretty-printing of the exception as done by my servlet).

The line of code this refers to is:

node.parentNode = this;

and 'node' was set by a call: NodeImpl node = (NodeImpl)getNodeObject(index);

I notice the getNodeObject can return null:

    // is there anything to do?
    if (nodeIndex == -1) {
        return null;
    }

but a null return value is not checked for in synchronizedChildren().

Can anyone suggest why this is happening and how I can fix it?

Many thanks,
Matt.

Reply via email to