Thursday, November 21, 2013

WebLogic Application Deployment & Shared Library

In an enterprise application deployment scenario, there are many cases where some libraries are used/referenced by multiple applications. It would indeed be a bad design to include such common libraries with every application deployed on the WebLogic server. Not only does it prevent redundancy of resources on the server, it also consumes valuable space & deployment time - especially when the libraries are huge.

WebLogic server offers the shared library concept using which EARs, JARs, EJBs and WARs can be shared across applications in a WebLogic domain.

Let us now see how to package and deploy a shared library in WebLogic server;

Step 1: Create a folder structure as shown below

Step 2: Copy all the libraries (in this case JAR files) that you would want to share across applications to the lib folder under WEB_INF
Step 3: Create a file under META_INF folder by name "MANIFEST.MF"
Step 4: Contents of the MANIFEST.MF file are shown below
Manifest-Version: 1.0
Specification-Title: CommonJars
Specification-Version: 1.0
Implementation-Title: CommonJars Implementation
Implementation-Version: 1.0
Implementation-Vendor: Oracle
Extension-Name: CommonJars
Step 5: From the root folder location, execute the following command to generate a WAR file
jar -cvf sharedlib.war *.*
Step 6: Now, login to Oracle WebLogic console, choose "Deployments" and deploy the generated WAR as a shared library - steps with screenshots below






Step 7: Now that the shared library is deployed, let us refer this shared library from another application

Open the weblogic.xml file. If it is not present in your application, create this file under WEB-INF folder of your application and refer the shared library as shown below;
<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
    <library-ref>
        <library-name>CommonJars</library-name>
    </library-ref>
</weblogic-web-app>

Enjoy sharing libraries across your enterprise applications.

4 comments:

  1. Hi, nice article and blog!
    I'm migrating an application from JBoss 7, and i want to know if i can use this "shared libraries" concept as the "modules" concept of JBoss.

    It is necessary to deploy the shared library as a WAR? or can i configure independent libraries (JARs) and use specific libraries on the applications i need to deploy?

    ReplyDelete
    Replies
    1. Yes daorte. You can either have JAR or WAR as shared libraries for reference within your applications.

      Delete
  2. In deployment was Succesfull .... but, in runtime i got a java.lang.NoClassDefFoundError: com/wl/library1/Usuario Caused By: java.lang.ClassNotFoundException:

    ReplyDelete