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!
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.
For those who would like to use even newer version of Jersey (works with 2.15 up to 2.20, which is currently in a SNAPSHOT version), this is another version of weblogic.xml
. Note that this set of package names is determined by single dependency to
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
File weblogic.xml
(includes also resources, which is not covered in AndreyBavt's answer and not even in the official doc):
<wls:container-descriptor>
<wls:prefer-application-packages>
<!-- jsr311 -->
<wls:package-name>javax.ws.rs.*</wls:package-name>
<!-- javassist -->
<wls:package-name>javassist.*</wls:package-name>
<!-- aop repackaged -->
<wls:package-name>org.aopalliance.*</wls:package-name>
<!-- jersey 2 -->
<wls:package-name>jersey.repackaged.*</wls:package-name>
<wls:package-name>org.glassfish.jersey.*</wls:package-name>
<wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
<!-- hk2 -->
<wls:package-name>org.glassfish.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.tiger_types.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</wls:resource-name>
<wls:resource-name>META-INF/services/javax.ws.rs.ext.RuntimeDelegate</wls:resource-name>
<!-- jersey -->
<wls:resource-name>META-INF/services/org.glassfish.jersey.*</wls:resource-name>
<wls:resource-name>org.glassfish.jersey.*</wls:resource-name>
<wls:resource-name>jersey.repackaged.*</wls:resource-name>
<!-- hk2 -->
<wls:resource-name>META-INF/services/org.glassfish.hk2.*</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
Tested with Weblogic 12.2.1
I had the same problem when I upgraded my Jersey to 2.22.
The Weblogic 12.1.3 uses the 1.18 version of Jersey. To upgrade to another one, you can deploy the Jersey 2.x as a library on Weblogic and shared with your applications or config Weblogic to use Jersey from your application by weblogic.xml.
In my case I choose the second option:
weblogic.xml:
<prefer-application-packages>
<package-name>javax.ws.rs.*</package-name>
<package-name>com.sun.jersey.*</package-name>
<package-name>org.glassfish.*</package-name>
<package-name>org.jvnet.hk2.*</package-name>
<package-name>jersey.repackaged.org.objectweb.asm.*</package-name>
</prefer-application-packages>
I have created a simple maven project to produce the war file with the 2.19 jersey shared library for weblogic.
You can clone from here weblogic-jax-rs
After cloning run mvn package
to produce the war and then deploy it to the server
As of weblogic 12.2.1 - there is jersey 2.21.1 bundled with it so no additional installations are required.
weblogic 12.2.1.1 comes with jersey 2.22.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With