Hi,
In my tomcat server, I'm trying to return an XML response by writing the response to the servlet's output stream, using a XALAN identity transformer.
The XML is valid, but from time to time I'm getting a NPE inside the transformer:
WARNING java.lang.NullPointerException
at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:302)
at org.apache.xalan.transformer.TransformerIdentityImpl.flushStartDoc(TransformerIdentityImpl.java:934)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
at org.apache.xml.serializer.TreeWalker.startNode(TreeWalker.java:359)
at org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:145)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:390)
This happens only sporadically, but often enough to be a real problem.
I've walked through xalan code and tried to figure out why this happens. Interactive debugging is a real problem in my case (very remote machine, problem doesn't reproduce all the time, etc.)
Has anyone encountered this kind of behavior before? or can lead me on some trail?
It seems that for some reason, the transformer code tries to create the m_resultContentHandler
when it should have been initialized.
I'm pretty sure the transformer is not called from two different threads.
The Xalan version is 2.7.1
The Tomcat version is 6.0.24
JRE: 1.6
Any ideas?
Thanks in advance,
- Lior
Code snippet:
Transformer t = getTransformer(); //Transformer is taken from an apache-commons GenericPool configured to grow if exhausted
StreamResult sr = new StreamResult(response.getOutputStream());
DOMSource ds = new DOMSource(d); //d is a Document created before this code
t.transform(ds,sr);