JAXB 2.1 and Jdk 6 problem

Jaxb is part of the jdk since jdk version 6. The earliest versions of the jdk 6 (update 1 till 3) have jaxb 2.0 included. The later versions of jdk 6 make use of jaxb 2.1.

Our pearlchain application makes use of camel which on its turn depends on jaxb version 2.1.  In order to be compatible with java version 5 we’ve added a maven dependency to this jaxb 2.1 jar. When running the application with java 5 we’ve encountered no problems however when running the application with jdk 6 some developers got the following error :

java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/Documents%20and%20Settings/steven/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.10/jaxb-impl-2.1.10.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)

Those developers were running the application with an earlier version of jdk 6 (update 1 -3).
There are 2 solutions:

  • update jdk6 to at least jdk update 4 release
  • use the guideline in the error message :  override jaxb 2.0 and put jaxb 2.1 jar before rt.jar in bootclasspath. See  http://java.sun.com/j2se/1.5.0/docs/guide/standards/ for more details about Endorsed Standards Override Mechanism.

We’ve chosen the first solution. However keep the second solution in mind when you can’t change the jdk6 to a more recent update release.

Cheers,

Steven

Comments are closed.