Wednesday, August 26, 2009

How to solve a weird JAXB/xerces spring application context load error

I was trying to get an app working standalone a spring application context via the classpath. In eclipse it worked fine but at the command line I got:
Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl @148cc8c] does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
I was using java 1.6 and the latest Xerces so this error message is not at all helpful. What was VERY helpful was finding the thread at http://forum.springsource.org/archive/index.php/t-21140.html which contained the answer. I need to define a couple of properties that force the factories for XML parsing. Just add the following as JVM parameters:
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

4 comments:

Brett Kromkamp said...

Thank you very much for posting this. I see that you posted this in 2009... well, almost five years later, in 2014, it really helped me to solve the same issue I was having with Spring Framework. Thanks again. Brett

로끄 said...

Thank you very much. You saved me!!

Haripriya Chintalapati said...

Thankyou

Blake Neal said...

Finding this was well-timed! It works even through Java 8-compliant projects. Thanks again!