Monday, April 28, 2008

NoSuchMethodError: javax.xml.parsers.DocumnentBuilderFactory.getSchema()

java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.getSchema()Ljavax/xml/validation/Schema;
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)

Cause: You are using a different version of the DocumentBuilderFactory class

Solution:

This version of the javax.xml.parsers.DocumentBuilderFactory is used by the xercesImpl.jar and is defined in the jaxp-api.jar

This class is defined in the following jars:
xml-apis.jar
xmlParserAPIs.jar
xercesImpl-2.8.1.jar
jaxp-api.jar

In addition, this class is also include in the JVM. The JVM implementation of this class does not define a getSchema() method.

The only jar that contains an implementation of the DocmentBuilderFactory with the getSchema() method defined is the jaxp-api.jar. In order for this implementation to be used instead of the JVM's implementation or the other jar's implementation, you must either endorse this jar or put this jaxp-api.jar at the top of the classpath.

No comments: