users@jaxb.java.net

Version conflicts with JAXB in NetBeans and JDK 1.6

From: Johnny Tolliver <jxt_at_ornl.gov>
Date: Tue, 15 May 2007 10:51:18 -0400 (EDT)

What version of JAXB is built in to JDK 1.6.0_01? I am experiencing some
conflicts. Here are the details.

I have a web app built with NetBeans 5.5 using the JAXB 2.0 that's bundled
with NetBeans. It has worked fine in Tomcat 5.5.23 up until we upgraded the
server machine to JDK 1.6.0_01. Now I see the following error:

.../WEB-INF/lib/jaxb-impl.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/)

Sounds like a version mismatch between the JAXB jars in Java 6 and the JAXB
jars bundled with my WAR file. My first thought was to not bundle the JAXB
2.0 jars provided by NetBeans into the WAR file. If I do that, after setting
the NB source version to 1.6, and try to the web app again, I get this
error:

java.lang.NoClassDefFoundError:
com/sun/xml/bind/marshaller/NamespacePrefixMapper

from the line of code that attempts to set the
com.sun.xml.bind.marshaller.namespacePrefixMapper property to my
NamespacePrefixMapper implementation.

If I remove that line, then all is well -- except for the namespace prefix
mapping, of course.

I see three possible sources of conflict:

1) the JAXB version I used when xjc-compiling the schema (which I can't
exactly remember)
2) the JAXB version used by NetBeans 5.5 when building the WAR
3) the JAXB version used by Tomcat running on JDK1.6.0_01

And I've got three questions:
1) How should I resolve all these possible conflicts? (I.e., what version of
JAXB should I use for the xjc-compile, and how can I get NB 5.5 to use that
same version?)

2) Same question but for NB 6.0 M9?

3) How can I get the namespace prefix mapping working again with the correct
versions of JAXB everywhere?

Thanks,
Johnny S. Tolliver
Oak Ridge National Laboratory
tolliverjs_at_ornl.gov, 865-574-1305