devsource360

WebLogic Server Shared Libraries – Including Jars

This item was filled under [ MISC. ]


In my last post about including static resources in shared libraries, I had a follow-up question about how to include multiple jar files in a library.  I alluded to it in my post, but here is a concrete example that should make it more clear.

Suppose I have 2 jars, that need to be deployed together, and I want to do that in a single shared library that my new web application will reference.

Foo.java – packaged in foo.jar

   1:  package com.oracle.otn.samples.wls;

   2:   

   3:  public class Foo 

   4:  {

   5:      public String toString()

   6:      {

   7:          return "Foo";

   8:      }

   9:  }

Bar.java – packaged in bar.jar – notice that Bar extends Foo, so unless both jars are available at runtime, we should expect to see an error.

   1:  package com.oracle.otn.samples.wls;

   2:   

   3:  public class Bar extends Foo {

   4:      

   5:      public String toString()

   6:      {

   7:          return super.toString() + "Bar";

   8:      }

   9:  }

To build a shared library for these, I simply construct a new packaging structure for this library that includes both foo.jar and bar.jar in the WEB-INF/lib of my shared library.  Of course I also need to configure a MANIFEST.MF.

Here is the file structure of my shared library I call manyjars.war.  The jars is in this library’s WEB-INF/lib directory will be added to the WEB-INF/lib of any application that references this library when the application is initialized.

   1:  d:\temp>jar -tf manyjars.war

   2:  META-INF/

   3:  META-INF/MANIFEST.MF

   4:  WEB-INF/

   5:  WEB-INF/lib/

   6:  WEB-INF/lib/bar.jar

   7:  WEB-INF/lib/foo.jar

Here is the MANIFEST.MF file:

   1:  Manifest-Version: 1.0

   2:  Specification-Title: ManyJars

   3:  Specification-Version: 1.0

   4:  Implementation-Title: ManyJars Implementation

   5:  Implementation-Version: 1.0

   6:  Implementation-Vendor: Oracle

   7:  Extension-Name: ManyJars

I can now deploy this shared library to WebLogic Server (or Oracle Enterprise Pack for Eclipse – OEPE – will do it for you if you configure the library there and refer to it in your application).  Here is how it looks in the console once it’s deployed.

ManyJars

In my new web application, I refer to the library in my weblogic.xml – again OEPE for insert this reference for you if you use the tooling:

   1:  <?xml version="1.0" encoding="UTF-8"?>

   2:  <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">

   3:      <wls:weblogic-version>10.3.2</wls:weblogic-version>

   4:      <wls:context-root>FooBarWeb</wls:context-root>

   5:      <wls:library-ref>

   6:          <wls:library-name>ManyJars</wls:library-name>

   7:          <wls:specification-version>1.0</wls:specification-version>

   8:          <wls:exact-match>true</wls:exact-match>

   9:      </wls:library-ref>

  10:  </wls:weblogic-web-app>

So now if I have a simple index.jsp that refers to the Bar class we showed earlier, it should all work:

FooBar

If I wanted to include these jars at the EAR level, the procedure would be similar, except that I would create an ear-based shared library packaging and instead of WEB-INF/lib, I would place the jars in APP-INF/lib.  Instead of referring to the shared library in weblogic.xml, I would use weblogic-application.xml.

You can download my files here if you want to try this.  Good luck.






Rate this topic:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Popularity: 121 views
You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.


WebLogic Server Shared Libraries – Including Jars Copyright: You should confirm all information about WebLogic Server Shared Libraries – Including Jars full version edition(freeware/shareware) before downloading or relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators or key gen, cd key, hacks, dvd rip is illegal and prevent future development of WebLogic Server Shared Libraries – Including Jars full version edition. Download links are directly from our publisher sites or from the link provided by users, torrent files or links from rapidshare.com, yousendit.com, megaupload.com, netload.in, storage.to or depositfiles.com are not allowed.