XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/dom

1.6k views Asked by At

My application is giving xpathfactory error on AIX which occurs at this line in the code XPathFactory xpf = XPathFactory.newInstance();.But,It's working fine on windows.I have extracted rt.jar which has XPathFactory class and gone through the code.From the data on Internet and through the code System property is checked first,if not found then jaxp.properties.If the above 2 are failed then it searches for jars in the classpath.I have set system property in both jaxp.properties and in appnode.tra.But,it's failing on AIX.How to print the jaxp logs and I want to make it work with out adding external jars in the classpath?(In jaxp.properties I have set the property as javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom=com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl)

1

There are 1 answers

2
Michael Kay On

I guess you're using the IBM JDK, and its default XPath implementation is something other than com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl -- which is perfectly legitimate.

On JDK9 there is a method XPathFactory.newDefaultInstance() so you don't have to know the name of the default factory any more.

Alternatively, try to see what gets loaded if you don't set any system properties and don't have anything on the classpath.