Support Classes Packaging in WebLogic
I am deploying an application as an EAR in Weblogic 6.0. I have a WAR
and a whole bunch of EJBs (jars) in the EAR. My question is: where should I
put the classes (jar files) that I both want to use from the WAR and the
EJBs? (Putting those in the system classpath is not an option here.)
When an EAR containing EJBs and a WAR is deployed in WebLogic 6, WebLogic
creates two class loaders. The first one is used to load all the EJBs. The
second one is used to load the WAR. The EJB class loader is the parent of
the WAR class loader. This means that every class visible from the EJB is
also visible from the WAR.
To make sure that a library (say library.jar) can be used from all the EJBs
and the WAR, include library.jar in the EAR and modify the manifest of each
EJB JAR file to add this line:
Class-Path: library.jar
In fact, since all the EJBs are loaded with the same class loader, you
just need to include the above Class-Path line in the first EJB loaded by
WebLogic. So if you don't want to include the Class-Path line in the
manifest of every EJB JAR, you can just put it in one of the EJB JAR and
make sure that this EJB JAR is loaded first using the DeploymentOrder
attribute of the EJBComponent in your WebLogic config.xml.