8
votes

I'm getting this error when trying to access my webservice running inside tomcat.

Caused by: java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/software/tomcat6/webapps/messaging/WEB-INF/lib/jaxb-impl-2.1.5.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/)

I googled for the error and did what should solve it (I put jaxb-api.jar, version 2.1 in JDK/lib/endorsed and JDK/jre/lib/endorsed) but it doesn't appear to have any effect.

I didn't have it before, and I'm not sure what was changed. I use JDK 6u10.

3
Take a look also to my answer to a similar question.bluish

3 Answers

8
votes

Java 6u10 includes JAXB 2.1, so there is no need to include it at all (it has been included since 6u4).

Right now it looks like you have a conflict between JAXB included with a webapp and the bundled JAXB that comes with JRE. You could try removing the JAXB jar from your webapp (C:/software/tomcat6/webapps/messaging/WEB-INF/lib/jaxb-impl-2.1.5.jar) and rely on the built-in version.

2
votes

The recommended way is to define the JAVA_ENDORSED_DIRS environmental variable. Then Tomcat will use this Java property:

-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS

in order to load the endorsed jars. So, create a folder, put jaxb-api.jar v2.1 there and define the environmental variable to point at that folder.

This is better than using the global endorsed directory, because it doesn't affect the whole JVM and you don't have to repeat the process, when the JRE is updated.

1
votes

Is it possible you have the jaxb jars in the $JAVA_HOME/jre/lib/ext directory? Here is the definition of the bootstrap loader:

Bootstrap - This class loader contains the basic runtime classes provided by the Java Virtual Machine, plus any classes from JAR files present in the System Extensions directory ($JAVA_HOME/jre/lib/ext). NOTE - Some JVMs may implement this as more than one class loader, or it may not be visible (as a class loader) at all.

(Taken form here)

Please search for all the places where you have the jaxb jars in the system (at least jaxb-api and jaxb-impl) and make sure that they are in either the WEB-INF/lib directory of your web application or in the lib directory of the tomcat.