andreybavt andreybavt - 5 months ago 97
Java Question

Using Jersey 2.x web service on Weblogic 12.1.1

I'm trying to deploy Jersey 2.13 web services to Weblogic 12.1.1. This version of weblogic is compliant with JSR-311 JAX-RS 1.1 specification whereas Jersey 2.x provides implementation for JAX-RS 2.0

Oracle has an instruction on how to upgrade the version of Jersey JAX-RS RI :
http://docs.oracle.com/cd/E24329_01/web.1211/e24983/version.htm

However even this doesn't help solving all of the deployment issues.

I'm packaging the application in EAR containing WAR. In order to override weblogic jars I've included added the following weblogic-application.xml file :

<?xml version="1.0" encoding="ISO-8859-1"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<prefer-application-packages>
<!-- apis -->
<package-name>javax.ws.rs.*</package-name>
<!-- guava -->
<package-name>com.google.common.*</package-name>
<!-- jersey1 providers -->
<package-name>com.sun.jersey.*</package-name>
<!-- media providers -->
<package-name>org.eclipse.persistence.jaxb.rs.*</package-name>
<package-name>org.codehaus.jackson.jaxrs.*</package-name>
<!-- wls -->
<package-name>weblogic.jaxrs.api.client.*</package-name>
<package-name>weblogic.jaxrs.internal.api.client.*</package-name>
<package-name>weblogic.jaxrs.dispatch.*</package-name>
<package-name>weblogic.jaxrs.monitoring.util.*</package-name>

</prefer-application-packages>
</weblogic-application>


This configuration gives me a following error message on deployment :

Caused By: java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;


If I try to replace org.glassfish.hk2.* classes by adding it to prefer-application-packages I receive new errors and it's continuing forever...

Has anyone migrated Jersey to version 2.x on weblogic 12.1.1 or below?

Thanks!

Answer

In the end it turned out that you actually have to replace more jars than Oracle suggests. Here's what my weblogic-application.xml looks like :

 <prefer-application-packages>
    <package-name>com.sun.jersey.*</package-name>
    <package-name>org.glassfish.jersey.*</package-name>
    <package-name>org.glassfish.hk2.*</package-name>
    <package-name>org.jvnet.hk2.*</package-name>
    <package-name>jersey.repackaged.org.objectweb.asm.*</package-name>

    <package-name>com.sun.research.ws.wadl.*</package-name>
    <package-name>com.sun.ws.rs.ext.*</package-name>

    <package-name>org.codehaus.jackson.*</package-name>
    <package-name>com.fasterxml.jackson.*</package-name>

    <package-name>org.codehaus.jettison.*</package-name>

    <package-name>javax.ws.rs.*</package-name>

    <package-name>org.objectweb.asm.*</package-name>

    <package-name>antlr.*</package-name>

  </prefer-application-packages>

Hope it helps.

Comments