Understanding WebLogic Server Application Classloading 8-3
8.1.4 Changing Classes in a Running Program
WebLogic Server allows you to deploy newer versions of application modules such as EJBs while the server is running. This process is known as hot-deploy or hot-redeploy
and is closely related to classloading.
Java classloaders do not have any standard mechanism to undeploy or unload a set of classes, nor can they load new versions of classes. In order to make updates to classes
in a running virtual machine, the classloader that loaded the changed classes must be replaced with a new classloader. When a classloader is replaced, all classes that were
loaded from that classloader or any classloaders that are offspring of that classloader must be reloaded. Any instances of these classes must be re-instantiated.
In WebLogic Server, each application has a hierarchy of classloaders that are offspring of the system classloader. These hierarchies allow applications or parts of applications
to be individually reloaded without affecting the rest of the system. Section 8.2,
WebLogic Server Application Classloading discusses this topic.
8.1.5 Configuring Class Caching
WebLogic Server now allows you to enable class caching for faster start ups. Once you enable caching, the server records all the classes loaded until a specific criterion is
reached and persists the class definitions in an invisible file. When the server restarts, the cache is checked for validity with the existing code sources and the server uses the
cache file to bulk load the same sequence of classes recorded in the previous run. If any change is made to the system classpath or its contents, the cache will be
invalidated and re-built on server restart.
The advantages of using class caching are:
■
Reduces server startup time.
■
The package level index reduces search time for all classes and resources. The cache uses optimization techniques to minimize the initial cache recording time.
Cache recording continues until a specific class has been recorded.
1.
To enable class caching, set an environment variable CLASS_CACHE=true for UNIX, set CLASS_CACHE=true for Windows in the startWebLogic script.
2.
Configure class caching using the following properties:
■
Logging: To debug class caching issues, turn on logging by placing the following system properties in the JAVA_OPTIONS for the section of the
startup script that enables caching.
-Dclass.load.log.level=finest -Dclass.load.log.file=tmpclass-load-log.txt
There are three levels of logging: fine, finer, finest. Do not enable logging during regular cache operation. Logging will slow the start up of the server.
Use logging for debugging only.
■
Recording limit: Though the recording limit for class caching is set to a specific class, you can configure this class in your environment to a different class.
Note: Class caching is supported in development mode when
starting the server using a startWebLogic script. Class caching is disabled by default and is not supported in production mode. The
decrease in startup time varies among different JRE vendors.
8-4 Developing Applications for Oracle WebLogic Server
-Dlaunch.complete=fully qualified class name for example com.oracle.component.Foo
The class used in this property must be in the system classpath for WebLogic Server.
Example 8–2 illustrates modified UNIX and Windows startWebLogic scripts with class
caching enabled and logging turned on.
Example 8–2 startWebLogic scripts
On UNIX CLASS CACHING
CLASS_CACHE=true if [ {CLASS_CACHE} = true ] ; then
echo Class caching enabled... JAVA_OPTIONS={JAVA_OPTIONS} -Dlaunch.main.class={SERVER_CLASS}
-Dlaunch.class.path={CLASSPATH} -Dlaunch.complete=weblogic.store.internal.LockManagerImpl
-Dclass.load.log.level=finest -Dclass.load.log.file=tmpclass-load-log.txt
-cp {WL_HOME}serverlibpcl2.jar export JAVA_OPTIONS
SERVER_CLASS=com.oracle.classloader.launch.Launcher fi
On Windows REM CLASS CACHING
set CLASS_CACHE=true if CLASS_CACHE==true
echo Class caching enabled... set JAVA_OPTIONS=JAVA_OPTIONS -Dlaunch.main.class=SERVER_CLASS
-Dlaunch.class.path=CLASSPATH -Dclass.load.log.level=finest -Dclass.load.log.file=C:\class-load-log.txt
-Dlaunch.complete=weblogic.store.internal.LockManagerImpl -cp WL_HOME\server\lib\pcl2.jar
set SERVER_CLASS=com.oracle.classloader.launch.Launcher
8.2 WebLogic Server Application Classloading