Classloader isolation policies
The number and function of the application module classloaders depends
on the classloader policies specified in the server 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 system. When set to SINGLE, applications are not isolated.
When set to MULTIPLE, applications are isolated from each other.
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 WAR classloader policy for the application.
The WAR classloader policy controls the isolation of web modules. If
this policy is set to APPLICATION, then the web module contents are loaded
by the application classloader (in addition to the EJB files, resource
adapter archive (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.
Note: WebSphere® Application Server classloaders never load
application client modules.
Click the link below for more information:
WebSphere
Application Server V5.0 information center - classloaders
Using the administrative console to change the WAR Classloader
Policy:
BASE product:
- Start the server
- startserver server1 (server1= your server name)
- after server is started, open the base node administrative console
- Expand the Applications -> Enterprise Applications -> select the
enterprise application
(in my example: I selected "petstore")
- Configuration tabs are in middle of the "General Properties" for the
WAR
Select the Classloader Policy drop down menu to select "Module" or
"Application"
- Save the changes
Using wsadmin to change the WAR Classloader Policy:
The script below sets the WAR classloader “policy”, which affects the
structure of the application classloader graph.
================Begin Script==========================
set deployments [$AdminConfig getid /Deployment:petstore/]
set deploymentObject [$AdminConfig showAttribute $deployments
deployedObject]
puts"*****************************************************************************************************"
puts $deploymentObject
puts"*****************************************************************************************************"
set war_classloader_policy [$AdminConfig showAttribute
$deploymentObject warClassLoaderPolicy]
puts "***************************"
puts $war_classloader_policy
puts "***************************"
#Set Variable for WAR Classloader Policy SINGLE=Application,
MULTIPLE=Module
puts "WAR Classloader Policy SINGLE=Application,
MULTIPLE=Module"
$AdminConfig modify $deploymentObject {{warClassLoaderPolicy
MULTIPLE}}
$AdminConfig save
set deploymentObject_New [$AdminConfig showAttribute $deployments
deployedObject]
set war_classloader_policy_New [$AdminConfig showAttribute
$deploymentObject_New warClassLoaderPolicy]
puts"*****************************************************************************************************"
puts $war_classloader_policy_New
puts"*****************************************************************************************************"
===============End Script=============================
OUTPUT Result:
C:\Program Files\WebSphere\AppServer\bin>wsadmin -f
warcl*.jacl
WASX7209I: Connected to process "server1" on node T23W2K using SOAP
connector; The type of process is: UnManagedProcess
************************************************************************************************************
(cells/T23W2K/applications/petstore.ear/deployments/petstore:deployment.xml#ApplicationDeployment_1)
************************************************************************************************************
*********************
SINGLE
*********************
WAR Classloader Policy SINGLE=Application, MULTIPLE=Module
************************************************************************************************************
MULTIPLE
************************************************************************************************************
C:\Program Files\WebSphere\AppServer\bin>
Using wsadmin to change the WAR Classloader Mode:
The script below changes the “WAR classloader “mode”, which affects how
the WAR classloader delegates the load operation. The WAR classloader mode
is only relevant if the WAR classloader policy is set to "Module".]
Example using the Petstore application:
==============Begin Script===========================
set deployments [$AdminConfig getid
/Deployment:petstore/]
set deploymentObject [$AdminConfig showAttribute $deployments
deployedObject]
set myModules [lindex [$AdminConfig showAttribute $deploymentObject
modules] 0]
set myWarModule [lindex $myModules 1] (you must
know specific index of module here)
$AdminConfig modify $myWarModule {{classloaderMode PARENT_LAST}}
$AdminConfig save
==============End Script============================
Both scripts obtain the deployment object for the application. The
scripts are different in that the above script further obtains the
specific WebSphere Application Server module and sets its classloader
mode. |