Reputation: 35
i'm trying to create a new instance of xpath factory, it is running perfectly without any problem in my local machine but in my ubuntu server(16.0) java 1.7 instance throwing following error.
SEVERE: Caught exception : javax.xml.xpath.XPathFactoryConfigurationException: No XPathFactory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:268)
I have read the following articles,
https://saxonica.plan.io/issues/1944
Syntax error in javax.xml.xpath.XPathFactory provider-configuration file of Saxon-HE 9.3
And updated my code like the following,
xPathfactory = XPathFactory.newInstance(
XPathFactory.DEFAULT_OBJECT_MODEL_URI, "net.sf.saxon.xpath.XPathFactoryImpl",
ClassLoader.getSystemClassLoader());
but it is still throwing the following error.
I'm using saxon 9.3.0.5 version in both my local and server instance.
I'm using this version because it gives much faster xslt conversion compare to the latest version.
What am i doing wrong? Any help would be greatly appreciated. Thanks in advance.
Upvotes: 3
Views: 2589
Reputation: 163262
First, if you've got a problem moving forward to a new Saxon release because of a performance regression, then in the interests of the user community as a whole I would strongly encourage you to work with us to get that problem identified and fixed, rather than sticking to an old version with known bugs.
I suspect you have correctly identified the issue. It has a long and convoluted history. IIRC (and this is probably a simplification): JDK 5 required the services file to be in a format that differed from the documented format, and Saxon used the format that worked. JDK 6 accepted the "wrong" format as well as the correct format. JDK 7 only accepted the correct format. As a result older versions of Saxon do not work with newer JDK versions - at least as far as this interface is concerned.
A workaround is to instantiate Saxon's XPathFactory directly (using new net.sf.saxon.xpath.XPathFactoryImpl()
) rather than using the JAXP search mechanism. This is in any case far more efficient.
Upvotes: 3