There is an upgrade guide for Jersey in the WebLogic 12.1.2 documentation but it doesn't cover upgrading to Jersey 2.x. That is exactly what I wanted to do however, the process is very similar to the 1.x upgrade.
My approach to using Jersey 2.x was to first package it as a shared library. I've previously covered how to package shared libraries for WebLogic deployment so will not cover it again here. How you package Jersey depends on the features you use, but in the minimum the following is required as a dependency (change version as required) - Servlet based server-side application...
pom.xml Maven Dependency
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version>
</dependency>
You're likely going to want other parts of Jersey as well, the modules list contains these. I had to use a number of media modules so I added those to my dependency list, e.g.
Maven Dependency
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25.1</version>
</dependency>
...
After the dependency list is put together, Maven can package and deploy the WAR file to WebLogic. That's not the end of the story though.
Assuming that your REST service is packaged as a WAR file, its weblogic.xml needs to be updated to reference the new shared library. That's just stock standard weblogic shared library usage. For example...
weblogic.xml
<library-ref>
<library-name>jersey</library-name>
<specification-version>2.0</specification-version>
<implementation-version>2.25.1</implementation-version>
<exact-match>true</exact-match>
</library-ref>
So far everything has been boiler plate WebLogic J2EE deployments. Unfortunately if you try to deploy/start your REST service now and have used Jersey 2.x features, it will fail to start. That's because WebLogic is still going to try and use its built-in Jersey 1.13 library. The upgrade guide I mentioned earlier covers this as well in some detail, but here's what you actually need to do...
In weblogic.xml the prefer-application-packages element needs to have entries added for ALL OF THE PACKAGES in the Jersey 2.x shared library JAR files. That means you need to go through every jar file in WEB-INF/lib for the shared library that was created with Maven and make sure the packages it defines are included in this element. See this article for a script that will generate this information for you.
For example...
weblogic.xml
<container-descriptor>
<prefer-application-packages>
<package-name>javax.ws.rs.*</package-name>
<package-name>org.glassfish.jersey.*</package-name>
...
</prefer-application-packages>
</container-descriptor>
The list of packages above is not exhaustive because it really depends on what features and modules of Jersey you require. Be sure not to use names that are too generic i.e. using the org.* package will cause problems. Once the package list in weblogic.xml is complete, your Jersey 2.x based REST service should deploy/start normally.
-i