Last Updated: February 25, 2016
·
11.56K
· stefanbirkner

JDOM2: This parser does not support specification "null" version "null"

When you have a Maven project which uses JDOM2 and you create a new SaxBuilder with new SaxBuilder() you will see a stack trace like this:

java.lang.ExceptionInInitializerError
  at org.jdom2.input.SAXBuilder.<init>(SAXBuilder.java:338)
  at org.jdom2.input.SAXBuilder.<init>(SAXBuilder.java:221)
  at your.package.your.class.your.method(Class.java:XX)
Caused by: java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
  at javax.xml.parsers.SAXParserFactory.setSchema(SAXParserFactory.java:419)
  ...

In that case you're using a SAXParserFactory that doesn't override setSchema(...). This may be a version of org.apache.xerces.jaxp.SAXParserFactoryImpl before 2.7.0.

There are two fixes for the problem.

Fix 1: Use a different SAXParserFactory by setting the system property javax.xml.parsers.SAXParserFactory. E.g. the factory provided by your current JDK: com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl. This may be done by starting the JVM with

-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

or within your code

System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");

Fix 2: Update the factory you're using. In case of apache's factory update it at least to version 2.7.0.

1 Response
Add your response

Very good!!!
Solved my problem. I've a mavem projet. The problem was just in this point: new SaxBuilder() and the stack was equals wich you showed.
I used the second option of Fix 1.

Thanks for a tip.

Att.;
Marcelo Rebouças

over 1 year ago ·