Classloader policies
The number and function of the application and application module classloaders depends on the classloader policies specified in the server and applcation configuration. Classloaders provide multiple options for isolating applications and modules to enable different application packaging schemes to run on an application server.
Two classloader policies control the isolation of applications and modules:
Application classloader policy
Application classloaders consist of EJB modules, dependency JAR files, resource adapters, and shared libraries. Depending on the application classloader policy, an application classloader can be shared by multiple applications (SINGLE) or unique for each application (MULTIPLE). The application classloader policy controls the isolation of applications running in the application server. When set to SINGLE, applications are not isolated. When set to MULTIPLE, applications are isolated from each other.To change the application classloader policy, perform these steps in the administrative console:
- Expand Servers and click Application servers.
- Click the server that you want to modify.
- Select the policy you want to use from the Application classloader policy drop-down box.
Click Apply and Save.
WAR classloader policy
By default, Web module classloaders load the contents of the WEB-INF/classes and WEB-INF/lib directories. The application classloader is the parent of the Web module classloader. You can change the default behavior by changing the application's WAR classloader policy.The WAR classloader policy controls the isolation of Web modules. If this policy is set to APPLICATION, then the Web module contents also are loaded by the application classloader (in addition to the EJB files, RAR files, dependency JAR files, and shared libraries). If the policy is set to MODULE, then each web module receives its own classloader whose parent is the application classloader.
To change the application's WAR classloader policy, perform these steps in the administrative console:
- Expand Applications and click Enterprise applications.
- Click the application that you want to modify.
- Select the policy you want to use from the WAR classloader policy drop-down box.
Click Apply and Save.
Note: Application client modules are not loaded by application classloaders.
Example scenarios
For each application server in the system, you can set the application classloader policy to SINGLE or MULTIPLE. When the application classloader policy is set to SINGLE, then a single application classloader loads all EJB modules, dependency JAR files, and shared libraries in the system. When the application classloader policy is set to MULTIPLE, then each application receives its own classloader used for loading that application's EJB modules, dependency JAR files, and shared libraries.
This application classloader can load each application's Web modules if that WAR module's classloader policy is also set to APPLICATION. If the WAR module's classloader policy is set to APPLICATION, then the application's loader loads the WAR module's classes. If the WAR classloader policy is set to MODULE, then each WAR module receives its own classloader.
This example shows that when the application classloader policy is set to SINGLE, a single application classloader loads all EJB modules, dependency JAR files, and shared libraries of all applications on the server. The single application classloader can also load Web modules if an application has its WAR classloader policy set to APPLICATION. Applications having a WAR classloader policy set to MODULE use a separate classloader for Web modules.
Application classloader policy: SINGLE Application 1 Module: EJB1.jar Module: WAR1.war MANIFEST Class-Path: Dependency1.jar WAR Classloader Policy = MODULE Application 2 Module: EJB2.jar MANIFEST Class-Path: Dependency2.jar Module: WAR2.war WAR Classloader Policy = APPLICATIONEJB modules, dependency JAR files, and shared libraries of all applications on the server." border="0">
This example shows that when the application classloader policy of an application server is set to MULTIPLE, each application on the server has its own classloader. An application classloader also loads its Web modules if the application's WAR classloader policy is set to APPLICATION. If the policy is set to MODULE, then a Web module uses its own classloader.
Application classloader policy: MULTIPLE Application 1 Module: EJB1.jar Module: WAR1.war MANIFEST Class-Path: Dependency1.jar WAR Classloader Policy = MODULE Application 2 Module: EJB2.jar MANIFEST Class-Path: Dependency2.jar Module: WAR2.war WAR Classloader Policy = APPLICATION