We have a Web Services Notification application that uses Xalan 2.7.0
(including xml-apis-1.3.03.jar, although I have also tried
xml-apis-1.3.04.jar).  The application contains the following code:


public boolean accepts(NotificationMessage message) {

        Document doc = XmlUtils.createDocument();
        logger.debug("doc = " + doc);
        Element messageXML = message.toXML(doc);
        ogger.debug("messageXML = " + messageXML);
        doc.appendChild(messageXML);
        logger.debug("appended doc = " + doc);

        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
                
        CompositeNamespaceContext namespaceContext = new
CompositeNamespaceContext();
        namespaceContext.addNamespaceContext(new ExtensionNamespaceContext());
        namespaceContext.addNamespaceContext(new SnaNamespaceContext());

        xpath.setNamespaceContext(namespaceContext);

        xpath.setXPathFunctionResolver(new XPathFunctionResolverImpl());

        try {
                boolean result = ((Boolean)xpath.evaluate(this._pattern, doc, 
                        XPathConstants.BOOLEAN)).booleanValue();
                logger.debug("result = " + result);
                return result;
        }
        catch (Exception error) {
                error.printStackTrace();
                return false;
        }
}



This code works fine in the Eclipse debugger (version 3.2.2 with JDK build
1.6.0-b105) using the Maven 2 dependencies plugin.  However, when we perform
a Maven build and deploy to Tomcat (version 5.5.20), we get the following
exception when XPathFactory.newInstance() is executed (bold line above):


java.lang.NullPointerException
        at
javax.xml.xpath.XPathFactoryFinder._newFactory(XPathFactoryFinder.java:222)
        at
javax.xml.xpath.XPathFactoryFinder.newFactory(XPathFactoryFinder.java:143)
        at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:185)
        at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:99)
        at
com.myorg.myapp.ws.notification.impl.ExtnMessagePatternFilter.accepts(ExtnMessagePatternFilter.java:69)
        at
org.apache.muse.ws.notification.impl.FilterCollection.accepts(FilterCollection.java:64)
        at
com.myorg.myapp.ws.notification.impl.BufferedSubscriptionManager.publish(BufferedSubscriptionManager.java:73)
        at
com.myorg.myapp.ws.notification.impl.NewsNotificationProducer.publish(NewsNotificationProducer.java:38)
        at
org.apache.muse.ws.notification.impl.SimpleNotificationProducer.publish(SimpleNotificationProducer.java:420)
        at com.myorg.myapp.ws.handler.DDSHandler.run(DDSHandler.java:304)
        at
com.myorg.commons.util.reactor.ReactorAdapter.run(ReactorAdapter.java:19)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)



Any ideas what might be going wrong?

-David
-- 
View this message in context: 
http://www.nabble.com/XPathFactory.newInstance%28%29-throwing-NullPointerException-tf4243595.html#a12075612
Sent from the Xalan - J - Users mailing list archive at Nabble.com.

Reply via email to