To solve the problem between JAXB2.1 and JDK1.6/6.0

Scenario 1
1.8. Using JAX-WS 2.1 with JavaSE6
JavaSE6 ships with JAX-WS 2.0 API in rt.jar, which causes some trouble when you try to run applications that use JAX-WS 2.1 API. This document collects information about how to solve this issue.

1.8.1. Endorsed directory
One way to fix this is to copy jaxws-api.jar and jaxb-api.jar into JRE endorsed directory, which is $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed)

Some application containers, such as Glassfish, modifies the location of the endorsed directory to a different place. From inside the JVM, you can check the current location by doing System.out.println(System.getProperty(“java.endorsed.dirs”));

Obviously you still need other JAX-WS jars in your classpath.

Please do not put all the jars to the endorsed directory. This makes it impossible for JAX-WS RI to see other classes that it needs for its operation, such as servlet classes on the server-side, or Ant classes in the tool time. As those are not loaded by the bootstrap classloader, you’ll get NoClassDefError on servlet/Ant classes.


Scenario 2

Support for JDK 1.6
Jbossws 2.0.1.GA is based on the jax-ws and jaxb versions 2.1. But JDK 1.6 ships jaxb 2.0 classes as part of the core distribution (rt.jar). So in order for the jboss jars to take precedent over the jdk supplied jars, we have to use the endorsed directory mechanism, as described here. The above link is for using jaxws ri 2.1, but we need jbossws 2.0.1. For that purpose copy the following 3 jars in to the jboss/lib/endorsed directory.

So assuming your jboss is setup in a directory /jboss and you have already installed jbossws 2.0.1 on top of it, Copy the following 3 files to /jboss/lib/endorsed.

The jboss run script is already configured to add the /jboss/lib/endoresed directory to the list of endorsed directory. So jars in this directory will take precedence over rt.jar.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.