Project

Profile

Help

NullPointerException-ReceivingContentHandle

Added by Anonymous over 15 years ago

Legacy ID: #5439257 Legacy Poster: Bruce Elmore (bhelmore)

I am having a problem with saxon parsing of web service request that has elements that don't have the namespace set. Here's the exception that I'm getting. 09:48:38,695 [] DEBUG [SoapMessageDispatcher] Endpoint invocation resulted in exception - respondin g with Fault java.lang.NullPointerException at net.sf.saxon.event.ReceivingContentHandler.getNameCode(ReceivingContentHandler.java:299) at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:216) at org.springframework.ws.soap.saaj.support.SaajXmlReader.handleElement(SaajXmlReader.java:1 42) at org.springframework.ws.soap.saaj.support.SaajXmlReader.handleNode(SaajXmlReader.java:125) at org.springframework.ws.soap.saaj.support.SaajXmlReader.handleElement(SaajXmlReader.java:1 52) at org.springframework.ws.soap.saaj.support.SaajXmlReader.handleNode(SaajXmlReader.java:125) at org.springframework.ws.soap.saaj.support.SaajXmlReader.handleElement(SaajXmlReader.java:1 52) at org.springframework.ws.soap.saaj.support.SaajXmlReader.handleNode(SaajXmlReader.java:125) at org.springframework.ws.soap.saaj.support.SaajXmlReader.parse(SaajXmlReader.java:117) at org.springframework.ws.soap.saaj.support.SaajXmlReader.parse(SaajXmlReader.java:98) at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:270) at net.sf.saxon.event.Sender.send(Sender.java:124) at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:28) at org.springframework.ws.server.endpoint.support.PayloadRootUtils.getPayloadRootQName(Paylo adRootUtils.java:86) at org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping .getLookupKeyForMessage(PayloadRootAnnotationMethodEndpointMapping.java:57) at org.springframework.ws.server.endpoint.mapping.AbstractMethodEndpointMapping.getEndpointI nternal(AbstractMethodEndpointMapping.java:56) at org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping.getEndpoint(Abstra ctEndpointMapping.java:83) at org.springframework.ws.server.MessageDispatcher.getEndpoint(MessageDispatcher.java:248) at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:201) at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:168) at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleCon nection(WebServiceMessageReceiverObjectSupport.java:88) at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebS erviceMessageReceiverHandlerAdapter.java:57) at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatche rServlet.java:230) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:461 ) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:426) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper. java:223) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletC ontext.java:3245) The problem is being caused by the fact that a null uri is being passed to the startElement method of the ReceivingContentHandler class. startElement calls getNameCode is calling uri.length() which throws the exception. Note that I am using 8.7 library, although this bug is also in the 9.1 library as well.


Replies (5)

Please register to reply

RE: NullPointerException-ReceivingContentHandle - Added by Anonymous over 15 years ago

Legacy ID: #5439346 Legacy Poster: Michael Kay (mhkay)

Thanks for reporting it. A null value for the URI parameter of the startElement() method of the SAX ContentHandler interface is not allowed according to the SAX API specifications, so you will have to find out why this parser is passing null. The offending code is in org.springframework.ws.soap.saaj.support.SaajXmlReader.handleElement(SaajXmlReader.java:1 42) I'm afraid I don't know who supports this code. If you can't get it fixed, you can work around the problem by inserting a SAX filter between the parser and Saxon that corrects the value to a zero length string. Michael Kay http://www.saxonica.com/

RE: NullPointerException-ReceivingContentHandle - Added by Anonymous over 15 years ago

Legacy ID: #5448325 Legacy Poster: Bruce Elmore (bhelmore)

I'll assume that you are correct on this. That said, the default implementation (com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler) does handle this situation gracefully. I might get push back from the developer's of the SpringFramework (SaajXmlReader) as well, since their code works with the reference implementation. I will pursue this option, if you are unwilling to fix it on your side. The fix for this is incredibly simple. I simply added the statement: if (s == null) s = ""; at the top of the startElement() method. I'd appreciate it, if you help me with this. Thanks. Bruce

RE: NullPointerException-ReceivingContentHandle - Added by Anonymous over 15 years ago

Legacy ID: #5448910 Legacy Poster: Michael Kay (mhkay)

I'm sorry, but this is a very critical interface where every instruction counts. I am not prepared to add code to my side of the interface to make it work with software that clearly doesn't conform to the contract. I've had many examples over the years where people have asked me to do this, and if I had done so each time, the code would now be littered with conditional code testing for special cases that should never occur. There are a few rare occasions when I will change my code to provide a workaround to bugs in other people's code. But I won't do it where it involves adding instructions to a path that is critical from a performance viewpoint, and where only a trivial number of users will benefit from the change. Michael Kay Saxonica

RE: NullPointerException-ReceivingContentHandle - Added by Anonymous over 15 years ago

Legacy ID: #5517493 Legacy Poster: Bruce Elmore (bhelmore)

OK. I've looked at using a SAX Filter (that is, subclassing XMLFilterImpl). It looks like this would be trivial to implement, but I'm clueless in how I can "inject" this filter given the call stack above (since I'm not instaniating an XMLReader, ContentHandler, etc. from within my code). Any suggestions? Thanks.

RE: NullPointerException-ReceivingContentHandle - Added by Anonymous over 15 years ago

Legacy ID: #5517747 Legacy Poster: Michael Kay (mhkay)

Looking further down the stack, I see that it's actually an IdentityTransformer that they're running: which means they've used JAXP to load whatever JAXP TransformerFactory happens to be lying around. Has Saxon been loaded because it's simply on the classpath, or because the javax.xml.transform.TransformerFactory system property points to it? In the first case, you may be able to get it to load Xalan instead by rearranging things on the classpath. If necessary, write your own TransformerFactory as a subclass of the Saxon one. In the second case, change the system property setting to point to Xalan, and then change any parts of the application that actually need Saxon to load it explicitly. As a matter of interest, what response have you had from the developers of springframework?

    (1-5/5)

    Please register to reply