Dear all,
 
We're using Xerces-J 1.0.1 in a server being developed, and getting a NullPointerException in org.apache.xerces.dom.DeferredDocumentImpl.
See line below (1218) where error occurs.
 
Still trying to find a way to reproduce the error but only clues we
have at the moment are that multiple clients could be running
the same piece of our corba server code simulteously.
 
Please let me know if i'm doing something stupid.
 
 
Here's the method that currently gets called to serialize server
results into a String to send back to the client.
 
 public static String getString( Element element ) throws Exception {
 
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  org.apache.xml.serialize.XMLSerializer serializer = createSerializer( baos );
  serializer.serialize( element );
  return baos.toString();
}
 
 
The createSerializer method just does this:
 
  org.apache.xml.serialize.XMLSerializer serializer = new XMLSerializer( out, _outputFormat );
 
where _outputFormat is a static defined with certain properties:
 
 static {
  _outputFormat.setOmitXMLDeclaration( true );
  _outputFormat.setIndenting( false );
  _outputFormat.setLineSeparator( "" );
 }
 
 
 
NullPointerException occurs in this method:
 
    /**
     * Synchronizes the node's children with the internal structure.
     * Fluffing the children at once solves a lot of work to keep
     * the two structures in sync. The problem gets worse when
     * editing the tree -- this makes it a lot easier.
     */
    protected void synchronizeChildren() {
 
        // no need to sync in the future
        syncChildren = false;
 
        getNodeType(0);
 
        // create children and link them as siblings
        NodeImpl last = null;
        for (int index = getFirstChild(0);
             index != -1;
             index = getNextSibling(index)) {
 
            NodeImpl node = (NodeImpl)getNodeObject(index);
            if (last == null) {
                firstChild = node;
            }
            else {
                last.nextSibling = node;
            }
            node.parentNode = this;          <= NullPointerException here
            node.previousSibling = last;
            last = node;
 
            // save doctype and document type
            int type = node.getNodeType();
            if (type == Node.ELEMENT_NODE) {
                docElement = (ElementImpl)node;
            }
            else if (type == Node.DOCUMENT_TYPE_NODE) {
                docType = (DocumentTypeImpl)node;
            }
        }
 
        if (last != null) {
            lastChild = last;
        }
 
    } // synchronizeChildren()

Reply via email to