« October 2009 | Main

November 2009 Archives

November 5, 2009

Oracle’s Brian Oliver on Data Grid Design Patterns

Last week I wrote about my experiences playing with the Coherence Inbator’s Push Replication Pattern and showed some screenshots of the JMX instrumentation with JConsole and my post is already out of date.  This week there has been a new release of the Coherence Incubator projects.   Another new development is that you now learn directly from the lead of the Coherence Incubator projects as InfoQ just posted a video presentation from Brian Oliver discussing several of the projects and the rationale behind them.  One announcement I’m particularly fond of is the new Examples project.  This should help jump-start those getting started with the Coherence Incubator as in prior releases the examples were in separate places and not as complete.  Cheers to the Incubator team for continuing to improve and share these patterns.

November 18, 2009

WebLogic Server Shared Libraries For Static Resources

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.

SharedLibExample

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
META-INF/
META-INF/MANIFEST.MF
oralogo_small.gif

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:

deployments

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.

weblogic.xml

<?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">
    <wls:weblogic-version>10.3.2</wls:weblogic-version>
    <wls:context-root>ImagesWeb</wls:context-root>
    <wls:library-ref>
        <wls:library-name>images</wls:library-name>
        <wls:specification-version>1.0</wls:specification-version>
        <wls:exact-match>true</wls:exact-match>
    </wls:library-ref>
</wls:weblogic-web-app>

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"/>

Conclusion

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.

About November 2009

This page contains all entries posted to James Bayer's Blog in November 2009. They are listed from oldest to newest.

October 2009 is the previous archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle