Home » Java » Enterprise Java » Creating a shared library for Jersey 2.19 to use with Weblogic 12.1.3

About Gerard Davison

Creating a shared library for Jersey 2.19 to use with Weblogic 12.1.3

Weblogic server comes with a shared library so you can deploy JAX-RS 2.0 applications; but is limited to Jersey version 2.5.1 and the instructions for changing this are not entirely obvious or straightforward. I have recently joined a new team at Oracle and one of the first things I did was to look at upgrading the dependent libraries. Now I have talked to the Jersey team and they don’t support this combination; but it maybe useful enough to get you out of a bind until the next version of Weblogic is released.

I am going to do this using Maven because it means all the packaging and downloading is done for you. The basic structure of the project is as follows:

| |-main
| | |-java
| | |-resources
| | | |-META-INF
| | | | |-MANIFEST.MF
| | |-webapp
| | | |-WEB-INF
| | | | |-web.xml
| | | | |-weblogic.xml

I just generated a vanilla Maven project using Netbeans and then added in the Jersey dependencies I needed, it is likely this file could be cut down a little bit more with some determination. But it worked well enough for me:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">



    <name>Jersey Library</name>




The next most important file in the MANIFEST.MF file, this tells Weblogic when you try to deploy the .war that this is a library and also contains the versions it supplies:

Specification-Title: Weblogic JAX-RS 2.0
Specification-Version: 2.0
Implementation-Title: Weblogic JAX-RS 2.0 Reference Implementation
Implementation-Version: 2.19
Extension-Name: jax-rs

Finally, you have to include a weblogic.xml file to tell the server that some classes you need to take from here rather than the server class loader. I got the basis of this from the file that comes with the 2.5.1 shares library that ships with 12.1.3 and then added a few more lines to take in account how the code has moved on. Depending on what your code is doing you may have to add a few more.

<?xml version="1.0" encoding="UTF-8"?>
        xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">

            <!-- apis -->

            <!-- guava -->

            <!-- jersey providers -->
            <!-- hk2 -->


            <!-- media providers -->

            <!-- wls -->

Now all this needs is a quick mvn install and in the target directory there will be a nice complete shared library called JerseyLibrary-2.9.war that you can deploy in the normal way. Remember of course to update the library entries for the .war that is going to depend on this to have the right versions in it so it does pick up the 2.5.1 version.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
7 years ago

Hi there
Thanks for this article..
I am trying to do the exact same thing – upgrade the rest library to latest version using shared library.. i wonder if I just put the latest jars in the WEB-INF/lib, wouldn’t weblogic just pick them up instead of me having to do setup this shared library thing ?
Any thoughts ?

Gerard Davison
7 years ago

Yes, you can do it this way also if you keep the weblogic.xml, this is the bit that allows it all to work.

7 years ago
Reply to  Gerard Davison

I wonder why Oracle documentation goes through the length of explaining how to create a shared library to upgrade the REST jars version then. If one can simply drop the jars in the web-inf/lib folder, isn’t it much easier approach than the shared library thing.. i will give it a shot to see if it works for me.

Gerard Davison
7 years ago
Reply to  leo

The reason for using a share library is just for saving memory and reducing the time it takes to deploy you application by externalising the dependency. Worth doing if you have more than one war that needs this or even to just reduce the build/deploy latency.

Rajeev Katamaneni
Rajeev Katamaneni
6 years ago

Great article but I am still left with a questions. Are you upgrading from Jersey 2.5.1 to 2.9 or downgrading to 2.19?