axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lior Wehrli <lior.weh...@adnovum.ch>
Subject NullPointerException when executing XPath expression on DOM Tree in Provider<SOAPMessage>
Date Fri, 02 Mar 2012 12:30:20 GMT
Hi,

I have implemented a JAX-WS service using the Provider<SOAPMessage> 
interface. I would like to extract elements from the SOAP request using 
XPath. But when I execute the XPathExpression on the SOAPPart of the 
message, I get this ugly NullPointerException. I assume that, since 
SOAPPart implements a DOM Document, this should work.

Here is an extract of my code:

public SOAPMessage invoke(SOAPMessage message) {
     XPathFactory factory = XPathFactory.newInstance();
     XPath xpathBuilder = factory.newXPath();
     XPathExpression xpath = 
xpathBuilder.compile("//OnBehalfOf/UsernameToken/Username/text()");
     Node node = (Node) xpath.evaluate(message.getSOAPPart(), 
XPathConstants.NODE);
}

The exception:

Caused by: javax.xml.transform.TransformerException: Unknown error in 
XPath.
     at org.apache.xpath.XPath.execute(XPath.java:363)
     at org.apache.xpath.XPath.execute(XPath.java:301)
     at 
org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:123)
     at 
org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:97)
     at 
org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:178)
     ... 38 more
Caused by: java.lang.NullPointerException
     at org.apache.xml.dtm.ref.dom2dtm.DOM2DTM.nextNode(DOM2DTM.java:387)
     at 
org.apache.xml.dtm.ref.DTMDefaultBase._nextsib(DTMDefaultBase.java:563)
     at 
org.apache.xml.dtm.ref.DTMDefaultBase.getNextSibling(DTMDefaultBase.java:1140)
     at 
org.apache.xml.dtm.ref.DTMDefaultBaseTraversers$ChildTraverser.next(DTMDefaultBaseTraversers.java:461)
     at org.apache.xpath.axes.AxesWalker.getNextNode(AxesWalker.java:333)
     at org.apache.xpath.axes.AxesWalker.nextNode(AxesWalker.java:361)
     at 
org.apache.xpath.axes.WalkingIterator.nextNode(WalkingIterator.java:192)
     at org.apache.xpath.axes.NodeSequence.nextNode(NodeSequence.java:281)
     at org.apache.xpath.axes.NodeSequence.runTo(NodeSequence.java:435)
     at org.apache.xpath.axes.NodeSequence.setRoot(NodeSequence.java:218)
     at 
org.apache.xpath.axes.LocPathIterator.execute(LocPathIterator.java:210)
     at org.apache.xpath.XPath.execute(XPath.java:335)

I use Axis2 1.6.1 and JBoss 5

Has anybody seen something like this? Am I doing something wrong? Or 
this a bug?

Thanks,

Lior

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message