I am trying to use XPathFactory to evaluate an expression in a Java application. But I get a Saxon error. At one time I used Saxon for some functionality, and for this I had to set the system property:
System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_SAXON, "net.sf.saxon.xpath.XPathFactoryImpl"); XPathFactory xpf = XPathFactory.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
However, now I just want to do some XML processing using the default DOM (org.w3c.dom.Document) and process it using xpath, so Saxon is not needed. But when I try to create XPathFactory, I still get the Saxon error message:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: net/sf/saxon/lib/EnvironmentVariableResolver at net.sf.saxon.xpath.XPathFactoryImpl.<init>(XPathFactoryImpl.java:26) ...
I even tried to "reset" the system property:
System.setProperty("javax.xml.xpath.XPathFactory:", "org.apache.xpath.jaxp.XPathFactoryImpl"); XPathFactory factory = XPathFactory.newInstance();
and
System.setProperty("javax.xml.xpath.XPathFactory:", "http://java.sun.com/jaxp/xpath/dom"); XPathFactory factory = XPathFactory.newInstance();
But this does not help, I still get the same error message.
How do I get rid of this to use XPathFactory by default again? (this worked fine before I tried using the saxon version)
source share