1

My application was initially working fine on Jboss5 and now I deployed it on Wildfly9. And I am getting below exception:

    Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.jersey.core.header.MediaTypes
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.jersey.core.header.MediaTypes
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:182)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
    at com.sun.jersey.api.client.Client.init(Client.java:343)
    at com.sun.jersey.api.client.Client.access$000(Client.java:119)
    at com.sun.jersey.api.client.Client$1.f(Client.java:192)
    at com.sun.jersey.api.client.Client$1.f(Client.java:188)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
    at com.sun.jersey.api.client.Client.<init>(Client.java:188)
    at com.sun.jersey.api.client.Client.<init>(Client.java:160)
    at com.sun.jersey.api.client.Client.create(Client.java:673)

Following jersey jars are already present in the lib but still I am getting this error. can anyone please help me with any pointer.

jersey-client-1.19.3.jar
jersey-core-1.19.3.jar
Ravi
  • 30,829
  • 42
  • 119
  • 173
Swpno
  • 173
  • 1
  • 13
  • Any particular reason why you're manually providing a different JAX-RS implementation along with the webapp while WildFly already provides its own (known as RESTEasy)? – BalusC Dec 27 '17 at 12:40
  • this application is using an external jar and that jar is using following: import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; – Swpno Dec 27 '17 at 13:42
  • 1
    I know. I'm just asking you why exactly you're doing that. All this mess with extra JARs is namely unnecessary. – BalusC Dec 27 '17 at 14:09

1 Answers1

1

As point by @BalusC, you don't need to add jersey bundle as wildfly9 comes along with RestEASY, which is similar to Jersey an implementation of JAX-RS. So, you are mixing jersey and resteasy in same application.

If you look at the exception, it is trying to load class from jersey

Could not initialize class com.sun.jersey.core.header.MediaTypes

So, you need to change the implementation to load from RestEASY (if you have something similar there)

Ravi
  • 30,829
  • 42
  • 119
  • 173