+

Search Tips   |   Advanced Search

Modify WAR class loader mode using wsadmin.sh

Use scripting and the wsadmin tool to modify WAR class loader mode for applications.

Start the wsadmin scripting client.

If an application is running, changing an application setting causes the application to restart. On stand-alone servers, the application restarts after we save the change. On multiple-server products, the application restarts after we save the change and files synchronize on the node where the application is installed. To control when synchronization occurs on multiple-server products, deselect Synchronize changes with nodes on the Console preferences page.

To modify WAR class loader mode for an application:


Tasks

  1. Set a reference to the deployment.xml document. For example:

    • Use Jacl:

      set deployments [$AdminConfig getid /Deployment:my_application/]
      

      Example output:

      application_name(cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#Deployment_1276887608391)
      

    • Use Jython:

      deployments = AdminConfig.getid('/Deployment:my_application/')
      

    Element Definition
    set is a Jacl command
    deployments is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object that represents the WAS configuration
    getid is an AdminConfig command
    Deployment is an attribute
    my_application is an application in the profile_root/config/cells/cell/applications/ directory

  2. Set a reference to the deployedObject attribute within the deployment.xml document and set it to the deployedObject variable. For example:

    • Use Jacl:

      set deploymentObject [$AdminConfig showAttribute $deployments deployedObject]
      

      Example output:

      (cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#ApplicationDeployment_1276887608391)
      

    • Use Jython:

      deploymentObject = AdminConfig.showAttribute(deployments, 'deployedObject')
      

    Element Definition
    set is a Jacl command
    deploymentObject is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object that represents the WAS configuration
    showAttribute is an AdminConfig command
    deployments is a variable to which the deployment.xml document is assigned
    deployedObject is an attribute within the deployment.xml document

  3. List the modules for the deployedObject attribute and set the list to the myModules variable. For example:

    • Use Jacl:

      set myModules [lindex [$AdminConfig showAttribute $deploymentObject modules] 0]
      

      Example output:

      (cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#WebModuleDeployment_1276887608391) 
      (cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#EJBModuleDeployment_1276887608391)
      

    • Use Jython:

      myModules = AdminConfig.showAttribute(deploymentObject, 'modules')
      myModules = myModules[1:len(myModules)-1].split(" ")
      print myModules
      

      Example output:

      ['(cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#WebModuleDeployment_1276887608391)', 
      '(cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#EJBModuleDeployment_1276887608391)']
      

    Element Definition
    set is a Jacl command
    myModules is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object that represents the WAS configuration
    showAttribute is an AdminConfig command
    deployedObject is an attribute within the deployment.xml document
    modules is an attribute within the deployment.xml document

  4. Find the web module and set the mode for the class loader. For example:

    • Use Jacl:

      foreach module $myModules {
           if {[regexp WebModuleDeployment $module] == 1} {
              $AdminConfig modify $module {{classloaderMode mode}}}}
      

    • Use Jython

      for module in myModules:
           if (module.find('WebModuleDeployment')!= -1):
              AdminConfig.modify(module, [['classloaderMode', 'mode']])
      

    Element Definition
    foreach is a Jacl command
    for is a Jython command
    module is an object being used modified
    $ is a Jacl operator for substituting a variable name with its value
    myModules is a variable name
    regexp is a function to use regular expression is used for searching within the previous commands
    module.find is a function to use regular expression is used for searching within the previous commands
    AdminConfig is an object that represents the WAS configuration
    modify is an AdminConfig command
    classloaderMode is an attribute within the deployment.xml document
    mode is the class loader mode value that to set for the WAR module. The mode value is either PARENT_FIRST or PARENT_LAST. See documentation about class loaders.

  5. Save the configuration, for example:

    • Use Jacl:

      $AdminConfig save
      

    • Use Jython:

      AdminConfig.save()
      

  6. Verify the changes that made to the attribute value with the showall command. For example:

    • Use Jacl:

      $AdminConfig showall $module
      

    • Use Jython:

      AdminConfig.showall(module)
      

      Example output:

      {applicationDeployment (cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#ApplicationDeployment_1276887608391)}
      
      {classloader (cells/cell/applications/application_name.ear/deployments/
      application_name|deployment.xml#Classloader_1276887608392)}
      {classloaderMode mode}
      {configs {}}
      {deploymentId 1}
      {startingWeight 10000}
      {targetMappings {(cells/cell/applications/application_nameear/deployments/
      application_name|deployment.xml#DeploymentTargetMapping_1276887608392)}}
      {uri WAR_file_name.war}
      


Related:

  • Class loaders
  • wsadmin AdminConfig
  • Commands for the AdminConfig object