Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I solve "java.lang.LinkageError: loader constraint violation" during execute Jersey 1.6 & axis2 1.3 in one web application?

I already have soap based web service running with axis2 1.3. These day, we have a plan to develop RESTful web service using Jersey 1.6.

I made web application( war file ) with axis2 1.3 and Jersey 1.6 and try to deploy it on jboss5.1.0.

After start jboss I saw below error message.

com.sun.jersey.api.container.ContainerException: Unable to create resource
    at com.sun.jersey.server.impl.resource.SingletonFactory$Singleton.init(SingletonFactory.java:139)
    at com.sun.jersey.server.impl.application.WebApplicationImpl$9.f(WebApplicationImpl.java:533)
    at com.sun.jersey.server.impl.application.WebApplicationImpl$9.f(WebApplicationImpl.java:531)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.getResourceComponentProvider(WebApplicationImpl.java:531)
.....
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:200)
    at com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:182)
    at com.sun.jersey.server.impl.resource.SingletonFactory$Singleton.init(SingletonFactory.java:137)
    ... 87 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.bind.JAXBElement.<init>(Ljavax/xml/namespace/QName;Ljava/lang/Class;Ljava/lang/Object;)V" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, com/sun/jersey/server/wadl/WadlGeneratorImpl, and the class loader (instance of <bootloader>) for resolved class, javax/xml/bind/JAXBElement, have different Class objects for the type javax/xml/namespace/QName used in the signature
    at com.sun.jersey.server.wadl.WadlGeneratorImpl.createResponse(WadlGeneratorImpl.java:194)
    at com.sun.jersey.server.wadl.WadlBuilder.generateResponse(WadlBuilder.java:397)
    at com.sun.jersey.server.wadl.WadlBuilder.generateMethod(WadlBuilder.java:166)
    at com.sun.jersey.server.wadl.WadlBuilder.generateResource(WadlBuilder.java:308)
    at com.sun.jersey.server.wadl.WadlBuilder.generateResource(WadlBuilder.java:271)
    at com.sun.jersey.server.wadl.WadlBuilder.generate(WadlBuilder.java:107)
    at com.sun.jersey.server.impl.wadl.WadlApplicationContextImpl.getApplication(WadlApplicationContextImpl.java:76)
    at com.sun.jersey.server.impl.wadl.WadlResource.<init>(WadlResource.java:76)
    ... 94 more
14:23:18,155 ERROR [[/oasapi]] Servlet /oasapi threw load() exception
java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.bind.JAXBElement.<init>(Ljavax/xml/namespace/QName;Ljava/lang/Class;Ljava/lang/Object;)V" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, com/sun/jersey/server/wadl/WadlGeneratorImpl, and the class loader (instance of <bootloader>) for resolved class, javax/xml/bind/JAXBElement, have different Class objects for the type javax/xml/namespace/QName used in the signature
    at com.sun.jersey.server.wadl.WadlGeneratorImpl.createResponse(WadlGeneratorImpl.java:194)
    at com.sun.jersey.server.wadl.WadlBuilder.generateResponse(WadlBuilder.java:397)
    at com.sun.jersey.server.wadl.WadlBuilder.generateMethod(WadlBuilder.java:166)
.....

Who can teach me what is problem and how I can solve this problem ?

Thanks

like image 707
user670097 Avatar asked Apr 04 '11 19:04

user670097


1 Answers

There are two versions of the javax.xml.namespace.QName class being provided in your environment:

  1. The first is in Java SE 6.
  2. The second appears to be provided by JBoss
like image 166
bdoughan Avatar answered Oct 20 '22 03:10

bdoughan