Saturday, November 23, 2013

Deploying Jersey (JAX-RS) RESTful Web Services on WebLogic Server

If you have to deploy a Jersey based RESTful web service on WebLogic server, you will have to deploy the jersey library on the WebLogic server and reference it from your weblogic.xml descriptor file.

WebLogic 11g comes bundled with Jersey library but we have to explicitly deploy & make it available for consumption. Use the following command to deploy the Jersey library on your WebLogic server;

java -classpath <Middleware_Home>/wlserver_10.3/server/lib/weblogic.jar weblogic.Deployer -verbose -noexit -source <Middleware_Home>/wlserver_10.3/common/deployable-libraries/jersey-bundle-1.9.war -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -password xxxxxx -deploy -library

This command would invoke the weblogic.Deployer which will deploy the Jersey bundle library as a shared library on your WebLogic server.

Now, all we need to do is to reference this library from the RESTful webservice application via weblogic.xml

<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
    <library-ref>
        <library-name>jax-rs</library-name>
        <specification-version>1.1</specification-version>
        <implementation-version>1.9</implementation-version>
        <exact-match>false</exact-match>
    </library-ref>
</weblogic-web-app>

Now, you can deploy your Jersey based RESTful webservice on WebLogic server.

3 comments:

  1. this is very nice article and very good information for Oracle Learners. our Cubtraining also provide all Oracle Courses

    ReplyDelete
  2. Hi Sathya,

    I tried the above configurations, deployed from Jdev 11g and it worked.
    I have an issue. If I want to use latest version of Jersey and Jax-RS, for example 2.0, then what are the configuration changes we will have to make. I don't want to deploy the library in weblogic, (soa 11g). Rather, I want to attach it as a jar file in my project.

    Regards,
    Nameet

    ReplyDelete
    Replies
    1. You could do that. But then you will have to attach the jar for every RS you deploy. Bloats your deployments...

      Delete