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 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: