Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.newInstance

This is the error from running a webapp deployed to appserver:


java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.newInstance(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljavax/xml/parsers/DocumentBuilderFactory;
The cause: there is an xml-apis.jar under JBOSS_HOME/lib/endorsed directory, and so javax.xml.* classes in xml-apis.jar override those same class from JDK. In particular, DocumentBuilderFactory class in xml-apis.jar is of old version and only has newInstance() method, but not newInstance(String, ClassLoader) method. DocumentBuilderFactory.newInstance(String factoryClassName, ClassLoader) is introduced in Java 6.

The fix is to remove xml-apis.jar from JBOSS_HOME/lib/endorsed directory. XML parser has been in Java proper for a long time, and there is no need for xml-apis.jar in most modern applications.


This post first appeared on Java How To ..., please read the originial post: here

Share the post

NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.newInstance

×

Subscribe to Java How To ...

Get updates delivered right to your inbox!

Thank you for your subscription

×