users@jersey.java.net

Re: [Jersey] ContextResolver , JSON and ERROR_JAXB_RI_2_1_10_MISSING()

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 16 Oct 2009 13:10:54 +0200

Hi Cemo,

What App server + version and JDK version are you using?

For GFv3 with JDK 6 there is a known issue that is causing the Jersey
code (you have presented) to use the version of JAXB in the JDK.
However, when one has the same code within the application (e.g. your
JAXBEntityContextResolver) it works fine. We think this might be an
OSGi related class loading bug.

Jakub is looking into this and can provide more details.

Paul.





On Oct 16, 2009, at 12:55 PM, Cemo Koc wrote:

>
> Hi,
>
> I have a little problem in my logs.
>
> I encountered this exception:
>
> The provider class, class
> com.xxx.providers.JAXBEntityContextResolver, could
> not be instantiated. Processing will continue but the class will not
> be
> utilized
> java.lang.RuntimeException: [failed to localize]
> error.jaxb.ri.2.1.10.missing()
>
> I checked my jars
>
> jaxb-impl-2.1.10.jar
> jaxb-api-2.1.jar
>
>
> Then I checked JSONConfiguration class
>
> public static Builder natural() {
> // this is to make sure people trying to use NATURAL notation
> will
> get clear message what is missing, when an old JAXB RI version is used
> try {
>
> Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
> } catch (ClassNotFoundException ex) {
>
> Logger.getLogger(JSONConfiguration.class.getName()).log(Level.SEVERE,
> ImplMessages.ERROR_JAXB_RI_2_1_10_MISSING());
> throw new
> RuntimeException(ImplMessages.ERROR_JAXB_RI_2_1_10_MISSING());
> }
> return new Builder(Notation.NATURAL);
> }
>
>
> I do not know why it is happening.
>
> This is also my context resolver:
>
>
> @Provider
> @Produces(MediaType.APPLICATION_JSON)
> public class JAXBEntityContextResolver implements
> ContextResolver<JAXBContext> {
>
> private JAXBContext context;
>
> public JAXBEntityContextResolver() throws Exception {
>
> AnnotatedClassScanner classScanner = new AnnotatedClassScanner(
> XmlType.class,XmlRootElement.class);
> Set<Class<?>> classes = classScanner.scan(new
> String[]{"com.yyy.entities","com.xxx.bean"});
> this.context = new
> JSONJAXBContext(JSONConfiguration.natural().build(),
> classes.toArray(new
> Class[classes.size()]));
> }
>
> public JAXBContext getContext(Class<?> objectType) {
> return context;
> }
> }
>
> I have not expected this exception in my logs.
>
> Any idea about this?
>
> Thanks
>
> --
> View this message in context: http://n2.nabble.com/ContextResolver-JSON-and-ERROR-JAXB-RI-2-1-10-MISSING-tp3834876p3834876.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>