Thursday, December 19, 2013

Adding JAR in the weblogic domain lib folder

The problem is: if I put a JAR in the $DOMAIN_HOME/lib folder, will it be actually added to the System classpath, and available to ANYTHING which turns inside WebLogic?
To test this, I create a class
public class Pippo {
 public static String ciao() {
  return "CIAO!";
 }
}


and export it to a file pvtestjava.jar, and put the jar in the domain/lib folder, and restart the whole thing.

IN THE SERVER STDOUT file (NOT in the log file...) I can see:

<Dec 19, 2013 11:23:38 AM CET> <Info> <Security> <BEA-090906> <Changing the default 
Random Number Generator in RSA CryptoJ from
 ECDRBG to FIPS186PRNG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true>
<Dec 19, 2013 11:23:38 AM CET> <Notice> <WebLogicServer> <BEA-000395>
 <Following extensions directory contents added to the end of the classpath:
/opt/oracle/domains/osbpl1do/lib/log4j_1.2.8.jar:
/opt/oracle/domains/osbpl1do/lib/pvtestjava.jar>
<Dec 19, 2013 11:23:39 AM CET> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 20.8-b03 from Sun Microsystems Inc.>



HOWEVER, refrain from rejoicing so soon. Not necessarily your application will see the JAR.
The documentation says
"" The JARS in the domain /lib directory will not be appended to the system classpath. The classloader that gets created is a child of the system classloader. Any classes that are in JARs in the domain /lib directory will only be visible to J2EE applications, such as EAR files. Classes in the system classpath cannot access classes in the domain /lib directory.""
For instance, the "Driver Interceptor:" to profile a Datasource will not be able to use this classpath extension mechanism. And if you dump the system classpath you will NOT see those domain/lib jars.

The EXTENSION classpath can be explicitly set with -Dweblogic.ext.dirs=$DOMAIN_HOME/lib

No comments: