Monday, May 12, 2014

Develop and Deploy Jersey RESTful service using JDeveloper in Weblogic

Jersey is one of reference implementations of JAX-WS specification which is to describe how REST should be implemented using annotation-driven POJO in Java. Jersey is the one that is most widely used in development and production. WebLogic Server ships with a set of pre-built shared libraries, packaged as Web applications. Jesery is one of these and it is required to run applications that are based on the Jersey JAX-RS RI. The version of Jsersey in weblogic 10.3 is 1.9 which implements JAX-RS 1.1.

This jersey war file is located in:  $Middleware/wlserver_10.3/common/deployable-libraries/jersey-bundle-1.9.war.

Register Jersey as the shared library in Weblogic server 

Before the REST application can be deployed and run on Weblogic the Jersey JAX-RS RI shared libraries needs to be registered in Weblogic Servcre instance. It can be done via Weblogic Console. 
Login into Weblogic Console Click on Deployments in Domain Structure
Click on Lock & Edit button to enable Install button and then click on Install button

The path should be:  /u01/app/fmwsodev/Middleware/wlserver_10.3/common/deployable-libraries
Select jersey-bundle-1.9.war and click on Next button

Select Install this deployment as a library and click on Next button

Select target and click on Next button

Select target and click on Next button

Confirm the library name, version and implementation version as below and click on Finish button

Now Jersey JAX-RS RI is registered as shared library in Weblogic server.  Any application deployed on the server can use this library for implementation of REST service using Jersey.

Develop Jersey REST service using JDeveloper

Create a generic project in JDeveloper

In order to develop Java codes which use Jersey to implement RESTful service, two jar files are needed to add into User Managed Libraries in JDeveloper.

First jar is jersey-bundle-1.9.jar which can be downloaded from:

Since jersey-bundle-1.9.jar doesn't include JAX-RS API classes.  So JAX-RS API jar is also needed.   The jar file can be found from Weblogic server installation folder: $Middleware/modules/

After two jar files are added into the libraries use these two libaries in the project: RESTProject by using Add Library in Libraries and Classpath from Project Properties... menu item.

Now create a POJO which will implement the service:

The source codes of Java class: RESTService are as below:


import com.toic.model.Folder;

import java.util.logging.Logger;


public class RESTService {
    private Logger logger = Logger.getLogger(RESTService.class.getName());
    public RESTService() {
    public Response getFoldersByGUID(@PathParam("folderguid") String folderguid) {
        Folder folder = Folder.makeFolders();
        return Response.status(Response.Status.OK).entity(folder).build();
The below is one domain class Folder which is used in RESTService class.

package com.toic.model;

import java.util.ArrayList;
import java.util.List;

public class Folder {
    private String folderName;
    private String owner;
    private String folderGUID;
    private String folderType;
    private List childFolders = new ArrayList();
    public Folder() {

    public String getFolderName() {
        return folderName;

    public void setFolderName(String folderName) {
        this.folderName = folderName;

    public String getOwner() {
        return owner;

    public void setOwner(String owner) {
        this.owner = owner;

    public String getFolderGUID() {
        return folderGUID;

    public void setFolderGUID(String folderGUID) {
        this.folderGUID = folderGUID;

    public String getFolderType() {
        return folderType;

    public void setFolderType(String folderType) {
        this.folderType = folderType;

    public List getChildFolders() {
        return childFolders;

    public void addChildFolder(Folder childFolder) {
    public static Folder makeFolders() {
        Folder rootFolder = new Folder();
        rootFolder.setFolderName("Root Folder");
        Folder childFolder1 = new Folder();
        Folder childFolder2 = new Folder();

        return rootFolder;

In editor click on Quick Fix to configure web.xml for this service.

web.xml is created under WEB-INF.

Update url-pattern to *

Then create Weblogic Deployment Descriptor

weblogic.xml file is created under WEB-INF as shown as below:

In run time the deployed service will use the shared library of Weblogic.  Here in weblogic.xml the library reference should be created as below:

Next step is to update the deployment profile of the service which is deployed as web application,

The service is called RESTService.

Update the context root as: Demo.

Deploy Jersey REST service and test the service

After all is done the service is ready to deploy to Weblogic server from JDeveloper.

If the deployment is successful RESTService will appear in the deployments of Weblogic Console.

Click on RESTService and click on Testing tab

Click on the Test Point URL to start browser and type in the url as: http://weblogicserverhost:8001/Demo/folders/guid/123456 and the service will respond as below:


  1. Mark, Thanks for the effort with this post. I ran into an issue deploying a rest appplication to a wls 10.3.6 server and the need to install the jax library as well as include it in my weblogic.xml escaped me. Thanks for the help

  2. Mark,

    What changes shall I do in web.xml and weblogic.xml to override loading of jersey and jax-rs jars from project web-inf/lib folder?