When running multiple instances of the same application in different partitions, you may want to optimize classloading memory across these instances. WebLogic Server MT includes a deployment-descriptor-based classloading feature for this purpose.
Note:WebLogic Server Multitenant domain partitions, resource groups, resource group templates, virtual targets, and Resource Consumption Management are deprecated in WebLogic Server 188.8.131.52.0 and will be removed in the next release.
The classloader feature is intended for use only by application developers. This chapter assumes that you are familiar with WebLogic Server application classloading, as described in Understanding WebLogic Server Application Classloading in Developing Applications for Oracle WebLogic Server. Read that chapter first if you are not familiar with WebLogic Server application classloading.
This chapter includes the following sections:
Configuring the Shared Application Classloader: Overview
WebLogic Server MT includes two new types of classloaders: partition classloaders and shared application classloaders.
Partition classloader: A partition classloader is created on your behalf for each partition. This classloader loads classes that must be visible to the entire partition and only that partition, and not to the rest of the domain. (This includes global connectors.)
Global connectors are a certain type of connector modules that are configured to be visible and available for all the applications in the server. These modules may be deployed standalone or may be deployed as a module of an Enterprise Archive (EAR) file.
Shared application classloader: The shared application classloader is relevant only in the Software-as-a-Service (SaaS) use case when an application is deployed to a resource group template. This classloader loads classes that should be visible to all the instances of an application across partitions, but not to other applications. Applications directly deployed to the domain (not to a partition) are not affected, even if partitions are configured.
WebLogic Server deployment descriptors support a new
shareableconfiguration to identify JAR files and classes under the
APP-INF/classesdirectory within the application packaging. These classes should be loaded from the shared application classloader.
shareableconfiguration is supported only in the
weblogic-application.xmlfile of enterprise applications, and only in production mode.
A new partition classloader is created when a partition is created and the first application for the partition is deployed to a resource group. An existing partition classloader is removed when a partition is removed and the last application for the partition is undeployed from a resource group.
A new shared application classloader may be created when an application (with sharable JAR files configured) is deployed to a resource group template and the resource group template is referenced by a resource group in a partition.
An existing shared application classloader is removed when the relevant application is undeployed from the resource group template. When you undeploy an application from a resource group template, it is immediately undeployed from any resource groups that reference that template.
You cannot assume that classloading will be shared. Sharing may or may not be possible. For example, if filtering is set up such that different configurations for each partition are obtained, then sharing is not possible. For information about filtering classloaders, see Using a Filtering ClassLoader in Developing Applications for Oracle WebLogic Server.
Therefore, you can indicate which JAR files are shareable, but cannot assume that the classes from these JAR files are loaded only once and shared.
Configuring the Shared Application Classloader: Main Steps
To configure a shared application classloader, application developers, using an XML editor, can edit the
weblogic-application.xml file and add one or more
shareable elements inside a
<class-loading> element when creating the application.
Consider the following example:
<class-loading> <shareable dir="APP-INF-LIB"> <include>coupon-generator.jar</include> <include>group-discounts.jar</include> </shareable> <shareable dir="LIB-DIR"> <exclude>program-guide.jar</exclude> </shareable> </class-loading>
dir attribute identifies the directory where subsequent patterns apply. The only supported values for
dir are as follows:
APP-INF-LIBidentifies the WebLogic Server-style
LIB-DIRidentifies the Java EE-style library directory.
APP-INF-CLASSESidentifies the WebLogic Server-style
LIB-DIR directories, the value that you set in
<include></include> elements identifies JAR files that you believe can be shared without any problems. The classes in these JAR files cannot be dependent on:
Classes in JAR files that are not considered shareable.
Partition-scoped classes such as global connectors.
Similarly, for the
LIB-DIR directories, the
<exclude></exclude> elements helps identify JAR files that must not be shared.
The following configuration rules apply:
LIB-DIRare identified without an include or exclude configuration, then all the JAR files of that directory are considered sharable.
LIB-DIRare identified with an include configuration, then only the JAR files identified with the include pattern are considered sharable.
LIB-DIRare identified with an exclude configuration, then all the JAR files of the directory except the JAR file identified by the exclude pattern are considered sharable.
APP-INF-CLASSES directory, include and exclude configurations are ignored, even if present. If you identify
APP-INF-CLASSES as sharable, then all the classes are declared sharable.
APP-INF-CLASSES directory is a code source location and does not require include and exclude elements. The shared application classloader implementation does not allow including or excluding elements within code source locations.
APP-INF-CLASSES directory is valid only for the packaging unit the descriptor is in, whether it is an application or library. You must declare it separately for the application and libraries.
Configuring the Shared Application Classloader: Related Tasks and Links
See the referenced information to learn about filtering classloaders.
Using a Filtering ClassLoader in Developing Applications for Oracle WebLogic Server.