users@jersey.java.net

Re: [Jersey] which version of JAXB works with jersey-json's JSONJAXBContext with natural format?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 16 Feb 2009 12:55:16 +0100

Hi James,

The Jersey JSON pom contains:

         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
             <version>2.1.10</version>
         </dependency>

You need version 2.1.10 to get "natural" support.

Annoyingly there is the usual issue of overriding the version of JAXB
in SE 6 for those using SE 6.

We need to do two things:

   1) have better error reporting on what version of JAXB to use when
configuration natural; and

   2) update the dependencies document.

Paul.

On Feb 13, 2009, at 6:43 PM, James Strachan wrote:

> When using the natural() format (which looks like being the one you're
> supposed to use right?) I get this exception using 2.1 and 2.1.6 of
> JAXB impl
>
> 13-Feb-2009 17:37:05 com.sun.jersey.core.spi.component.ProviderFactory
> _getComponentProvider
> SEVERE: The provider class, class
> org.apache.camel.rest.util.JAXBContextResolver, could not be
> instantiated
> javax.xml.bind.JAXBException: property "retainReferenceToInfo" is
> not supported
> at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
> 63)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun
> .reflect
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun
> .reflect
> .DelegatingMethodAccessorImpl
> .invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:211)
> at javax.xml.bind.ContextFinder.find(ContextFinder.java:372)
> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
> at
> com.sun.jersey.api.json.JSONJAXBContext.<init>(JSONJAXBContext.java:
> 256)
> at
> org
> .apache
> .camel.rest.util.JAXBContextResolver.<init>(JAXBContextResolver.java:
> 50)
>
>
> The work around is to avoid using this
>
> JSONConfiguration.Builder builder =
> JSONConfiguration.natural();
>
> as the samples do, but use another one of the deprecated formats like
>
> JSONConfiguration.Builder builder = JSONConfiguration.mapped();
>
> I just wondered is this a version clash? (I'm using Java 5 BTW - maybe
> noone has seen it as it works with the Java 6's JAXB impl?).
>
> Not a huge biggie - just wondered going forward what version of JAXB
> impl should be used with Java 5 when using the preferred JSON/JAXB
> configuration
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>