Simon Nash wrote:
Millies, Sebastian wrote:
indeed removing %TUSCANY_HOME%\lib from the client's classpath works
around the problem.
I've done a simple text search for "JAXBContext" on the source code.
The class org.apache.tuscany.sca.databinding.jaxb.JAXBContextCache
creates JAXBContexts and uses classloaders, so maybe if the
application classloader does not have the built-in versions
first, something goes wrong there.
Tuscany isn't running on the client side, so I don't think this is where
the client's JAXBContext is being created. I'm trying to create a test
case to reproduce the problem myself so that I can investigate further.
Simon
-- Sebastian
From: Simon Nash [mailto:[email protected]]
Sent: Wednesday, September 08, 2010 12:16 PM
To: [email protected]
Subject: Re: FW: JAXB 2.1 incompatibilty between Tuscany 1.6 and JDK
1.6.0_18
[snip]
What's puzzling me is that both JAX-WS and JAXB are part of the
JDK and I would have expected the built-in versions to be picked up
by the client code in preference to anything on the classpath.
There must be some code somewhere that's creating a JAXBContext by
looking on the classpath. I'll try to figure out where the
JAXBContext is getting created.
Simon
[snip]
The problem occurs because tuscany-sca-manifest contains jaxb-impl-2.1.7.jar
and this contains a META-INF/services/javax.xml.bind.JAXBContext file that
sets the JAXBContext implementation class to com.sun.xml.bind.v2.ContextFactory.
When running on JDK 6, the JAXB API built in to JDK6 finds this
META-INF/services/javax.xml.bind.JAXBContext file in the classpath and
therefore uses the implementation classes from jaxb-impl-2.1.7.jar in
preference to those contained within JDK 6.
This seems rather odd, but it works OK until we bring JAX-WS into the
picture. The tuscany-sca-manifest doesn't include jaxws-rt-2.1.7.jar,
so we get the JDK built-in version of the JAX-WS implementation classes.
These are incompatible with the non-built-in version of the JAXB
implementation that we're using, hence the ClassCastException.
The solution is to ensure there is a matched pair of JAXB and JAX-WS
implementations: either both built in to JDK 6, or both not built in to
JDK 6. If tuscany-sca-manifest is on the classpath, it's not possible
to avoid using the non-built-in JAXB implementation. This means that it's
necessary to also add jaxws-rt-2.1.7.jar to the classpath. This jar
contains a META-INF/services/javax.xml.ws.spi.Provider file that causes
the JAX-WS API in JDK 6 to load the non-built-in JAX-WS implementation
from jaxws-rt-2.1.7.jar. Alternatively, both tuscany-sca-manifest and
jaxws-rt-2.1.7.jar can be omitted from the classpath.
Simon