3
votes

On WebLogic 10.0 I use the "Shared J2EE Libraries" ( http://download.oracle.com/docs/cd/E11035_01/wls100/programming/libraries.html ) feature of WLS to group some jars which would need to be accessible in multiple ear's. These jars resided on the system classpath, and I try to move them into the shared lib from there.

My problem is:

  • in the WLS web admin console I click the shared library (named "theSharedLib") under Deployments
  • the "Applications that reference this Library" list is empty
  • I can also undeploy the lib using weblogic.Deployer, but on the next restart of the server it complains about the referenced library missing when loading the referencing application

So it seems that at startup the referencing takes effect, but in runtime WLS somehow forgets about this (do I need some magic trick here?).

I could also achieve this:

  • undeploy theSharedLib (no complaining)
  • undeploy someReferencingApp (ok)
  • deploy someReferencingApp (error! missing lib)
  • deploy theSharedLib (ok)
  • deploy someReferencingApp (ok; app gets listed in the web console; however on next restart, or after random other deployments, the list gets empty again)

Structure of shared lib ear in exploded directory format:

  • META-INF
    • MANIFEST.MF
    • application.xml
  • lib
    • (stuff I need to share as jars)
  • dummyejb.jar (because it has to contain something)

MANIFEST.MF contains:
..
Extension-Name: theSharedLib
Specification-Version: 1.0
Implementation-Version: 1.0.0
..

application.xml contains basic elements (one dummyejb ejb module).

Structure of referencing app:

Among others, it has META-INF/weblogic-application.xml, containing:

<?xml version="1.0"?>
<weblogic-application>
<library-ref>
<library-name>theSharedLib</library-name>
<specification-version>1.0</specification-version>
<implementation-version>1.0.0</implementation-version>
<exact-match>true</exact-match>
</library-ref>
</weblogic-application>

What could be the problem? Should I do anything else in the shared lib or in the referencing apps to (1) have the references list correctly and most importantly (2) share the jars among the apps?

I presume the shared jars inside the lib are loaded using the same classloader in the shared lib for each application, behaving pretty much like the sys classpath behavior. Could you please also confirm this?

Thanks!

2
I'm sorry (because you took time to type a lengthy question) but it is not clear if your shared library is actually well deployed or not. Can you clarify the problem?Pascal Thivent
@Pascal: Yes, I deployed the shared library using weblogic.Deployer ... -library with success. In the web console, the status of the deployed library is "Library". Without the shared lib being deployed, referencing apps complain at domain startup and get the status "New", but even if the shared lib is deployed, the described effects are seen.ron
Weird, things look good. Are the JARs in lib referenced in the MANIFEST.MF?Pascal Thivent
@Pascal: No, they are not, should they? In which Manifest file, the shared lib or the app one (and how)? Could you please expand on this a bit?ron

2 Answers

1
votes

Thanks for the information. Actually this is what I found out:

1) The listings of referencing applications disappear from the web console, if a referencing application fails at deployment (strange - maybe it has deeper reasons, but this is quite consistent now).

2) Unfortunately the classes inside a shared lib are loaded by the classloaders of the different referencing applications, so this way it is not possible to share for example interface classes for inter-application communication purposes.

0
votes

I think that the MANIFEST.MF of the shared lib (which is an EAR) should contain a Class-Path entry referencing the JARs in lib (this tells the classloader where to look to find classes). Something like this:

Class-Path: lib/foo.jar lib/bar.jar lib/foobar.jar