WebLogic Server Shared Libraries For Static Resources

Guest Author

In the OTN WLS General forum someone asked a question regarding using Shared Libraries to share static web resources among applications.  “Basically, we are trying to load jquery, css files, shared images, and what not into a shared library for access from other Web Applications.”  Shared libraries will handle this use case well.  I’ve put together a basic example using a simple image that is put into a shared library that is referenced by another web application.  The image in the screen shot below is from a shared library.  The web application that references it simply contains the JSP and a reference to the shared library in the weblogic.xml deployment descriptor.


Basic Steps

  1. Assemble the resources (images, css, etc) in a base directory, with subdirectories if desired
  2. In the main directory, create a META-INF/MANIFEST.MF file describing the library
  3. Package the base directory as a WAR file
  4. Deploy the WAR as a library to WLS
  5. Refer to the Shared Library in a web application’s WEB-INF/weblogic.xml
  6. Refer to the static resources from the library in the web application as if they are local to your application

Here is the link to the full documentation that describes all of the options for Shared Libraries in WebLogic.

Simple Example

I recommend taking a look at the shared libraries that ship with WebLogic Server to use as an example.  In WLS 10.3.x they are located here: <MIDDLEWARE_HOME>\wlserver_10.3\common\deployable-libraries

Here is what my META-INF/MANIFEST.MF file looks like for my example, I simply copied an existing MANFIEST.MF from jsf-1.2.war and made edits:

Manifest-Version: 1.0
Specification-Title: Images
Specification-Version: 1.0
Implementation-Title: Images Implementation
Implementation-Version: 1.0
Implementation-Vendor: Oracle
Extension-Name: images

Here is what the packaging of the library looks like after zipping it up as a WAR file:

C:\temp\images>jar -tf images.war

As you can see, it’s only a simple WAR file with an oracle image in the base directory with a META-INF/MANIFEST.MF file describing the library.  To deploy this to the WLS, you can do that as normal other than noting that it is a library.  After doing that it will show up like this in the console:


If you’re using Oracle Enterprise Pack for Eclipse and set your Windows->Preferences->Server->Runtime Environments correctly, then the existing shared libraries should be available in Preferences->WebLogic->Shared Libraries and you can add the library you just created to the list.  This will allow you to edit the WEB-INF/weblogic.xml in the IDE with a dialog box, correctly specify the reference to the shared library, and deploy the shared library for you to the server if it has not been done already when you deploy the application.


<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">

Now in the index.jsp, I can simply refer to the image as if it were in my base directory of the application like this:

<img src=""oralogo_small.gif"/>


Shared libraries are usually used to share code such as jars and class files in WARs and EARs, but they can also be used to share static resources.  So let’s say I wanted to share a jar file, I would have a WEB-INF/lib directory in my shared library, and put any jars that I wanted my application’s to have in there.  If it is an EAR file, then I would use APP-INF/lib.

You can download this extremely simple example here.  I tested this with WLS 10.3.2 also known as 11g PS1.

Join the discussion

Comments ( 6 )
  • subh Tuesday, December 15, 2009
    Am very well able to deploy a shared library and an application that refers to that library, independently. and it worked!!
    But, problem is that I have atleast 14/15 jars that needs to packaged either in a jar or ear and to be deployed.
    These jars has some other jars added in the classpath of their manifest file.
    After I follow the normal process, while deploying the application it still searches for those libraries even though they are deployed. I got to understand that its unable to refer to the jars inside the deployed libraryjar.
    It works wen I work with a single jar deployed as library but does not if I deploy a jar (consisting of multiple jars).
    Problem with deploying the libraries as EAR is that it searches an application.xml file and we dont have any module that can be referred inside that xml file.. I mean why would I need a module?
    Please help
  • james.bayer Tuesday, December 15, 2009
    I put my reply in a new post. I hope this helps you.
  • sharath Tuesday, December 29, 2009
    Hi James,
    Say I have 15 .jar files in ‘myLibrary.war’ and it is deployed in weblogic as library type.
    I used myLibrary(Extension-Name) in other web application(say myWebApp.war), in myWebApp application it is having other .jar files(not included in myLibrary.war) placed in /WEB-INF/lib folder of myWebApp.war.
    When I deploy myWebApp.war file, it is throwing errors(it is not looking .jar files placed in /WEB-INF/lib folder)? If I copy these .jar files under myLibrary.war then application is working fine.
    I’m thinking that weblogic will first take .jar files placed in shared library and if .jar file is not found then it will read local /WEB-INF/lib(project specific) directory. I mentioned following values in weblogic.xml file
    library-name - myLibrary
    exact-match - false
    Can you please correct me, how to resolve this issue having some .jar files in project specific folder(/WEB-INF/lib) directory and these .jar files are not available in shared library.
    Thanks in advance.
    Sharath Karnati.
  • james.bayer Tuesday, December 29, 2009
    To understand what WLS is doing with the libs, check out the weblogic.appmerge command line or ant task utilities. At deploy-time, WLS merges all the shared libraries and optional packages with your archive files. If you have over-ridden any of the files in the shared library by putting them in your archive, then your archive takes precedence.
  • Karthic Friday, February 19, 2010
    I am working on a Weblogic portal 10.3 migration project, where in I get an exception stating java.lang.NoSuchMethodError: com.bea.portlet.adapter.faces.FacesContentStub.getFacesRequest, but I could see the jar responsible to hold this class & the method is available in the WEB-INF/lib folder of the app. In spite of that I get the same error. Could any one help me please.
  • james.bayer Saturday, February 20, 2010
    java.lang.NoSuchMethodError usually means that you're using a different version of a class at runtime than you compiled against.
    I encourage you to open a support case to get some help. It's likely that somewhere in the migration a step was missed or similar.
    The OTN WebLogic Portal forum is another place you can ask.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.