+

Search Tips   |   Advanced Search

Configure a shared library for an application using wsadmin.sh

This task uses the AdminConfig object to configure a shared library for an application. Shared libraries are files used by multiple applications. Create a shared library to reduce the number of duplicate library files on the system.

There are two ways to complete this task. The example in this topic uses the AdminConfig object to create and configure a shared library. Alternatively, we can use the createSharedLibrary script in the AdminResources script library to configure shared libraries.

The scripting library provides a set of procedures to automate the most common administration functions. We can run each script procedure individually, or combine several procedures to quickly develop new scripts.


Tasks

  1. Start the wsadmin scripting tool.
  2. Identify the shared library and assign it to the library variable. We can either use an existing shared library or create a new one, for example:

    • To create a new shared library...

      1. Identify the node and assign it to a variable, for example:

        • Jacl:
          set n1 [$AdminConfig getid /Cell:mycell/Node:mynode/]
          
        • Jython:
          n1 = AdminConfig.getid('/Cell:mycell/Node:mynode/')
          
          print n1
          

        Element Description
        set Jacl command
        n1 Variable name
        $ Jacl operator for substituting a variable name with its value
        AdminConfig is an object representing the WebSphere Application Server configuration
        getid AdminConfig command
        Cell is the object type
        mycell is the name of the object that will be modified
        Node is the object type
        mynode is the name of the object that will be modified
        Example output:

        mynode(cells/mycell/nodes/mynode|node.xml#Node_1)
        

      2. Create the shared library in the node. The following example creates a new shared library in the node scope. We can modify it to use the cell or server scope.

        • Jacl:

          (Dist)

          set library [$AdminConfig create Library $n1 {{name mySharedLibrary} 
          {classPath c:/mySharedLibraryClasspath}}]
          
          (ZOS)
          set library [$AdminConfig create Library $n1 {{name mySharedLibrary} 
          {classPath /mySharedLibraryClasspath}}]
          
        • Jython:

          (Dist)

          library = AdminConfig.create('Library', n1, [['name', 'mySharedLibrary'], 
          ['classPath', 'c:/mySharedLibraryClasspath']])
          
          print library
          
          (ZOS)
          library = AdminConfig.create('Library', n1, [['name', 'mySharedLibrary'], 
          ['classPath', '/mySharedLibraryClasspath']])
          
          print library
          

        Element Description
        set Jacl command
        library variable name
        $ Jacl operator for substituting a variable name with its value
        AdminConfig object representing the WAS configuration
        create n AdminConfig command
        Library n AdminConfig object
        n1 Evaluate to the ID of host node specified in step number 1
        name Attribute
        mySharedLibrary Value of the name attribute
        classPath Attribute
        /mySharedLibraryClasspath Value of the classPath attribute
        Example output:

        MySharedLibrary(cells/mycell/nodes/mynode|libraries.xml#Library_1)
        

    • To use an existing shared library, issue the following command:

      • Jacl:
        set library [$AdminConfig getid /Library:mySharedLibrary/]
        
      • Jython:
        library = AdminConfig.getid('/Library:mySharedLibrary/')
        print library
        

      Element Description
      set Jacl command
      library variable name
      $ Jacl operator for substituting a variable name with its value
      AdminConfig object representing the WAS configuration
      getid n AdminConfig command
      Library Attribute
      mySharedLibrary Value of the Library attribute
      Example output:

      MySharedLibrary(cells/mycell/nodes/mynode|libraries.xml#Library_1)
      

  3. Identify the deployment configuration object for the application and assign it to the deployment variable. For example:

    • Jacl:
      set deployment [$AdminConfig getid /Deployment:myApp/]
      
    • Jython:
      deployment = AdminConfig.getid('/Deployment:myApp/')
      
      print deployment
      

    Element Description
    set Jacl command
    deployment variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object representing the WAS configuration
    getid n AdminConfig command
    Deployment Attribute
    myApp Value of the Deployment attribute
    print Jython command
    Example output:

    myApp(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Deployment_1)
    

  4. Retrieve the application deployment and assign it to the appDeploy variable. For example:

    • Jacl:
      set appDeploy [$AdminConfig showAttribute $deployment deployedObject]
      
    • Jython:
      appDeploy = AdminConfig.showAttribute(deployment, 'deployedObject')
      
      print appDeploy
      

    Element Description
    set Jacl command
    appDeploy variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object representing the WAS configuration
    showAttribute n AdminConfig command
    deployment Evaluate the ID of the deployment configuration object specified in step number 2
    deployedObject Attribute of modify objects
    print Jython command
    Example output:

    (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#ApplicationDeployment_1)
    
  5. Identify the class loader in the application deployment and assign it to the classLoader variable. For example:

    • Jacl:
      set classLoad1 [$AdminConfig showAttribute $appDeploy classloader]
      
    • Jython:
      classLoad1 = AdminConfig.showAttribute(appDeploy, 'classloader')
      
      print classLoad1
      

    Element Description
    set Jacl command
    classLoad1 variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object representing the WAS configuration
    showAttribute n AdminConfig command
    appDeploy Evaluate the ID of the application deployment specified in step number 3
    classLoader Attribute of modify objects
    print Jython command
    Example output:

    (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Classloader_1)
    
  6. Associate the shared library in the application through the class loader. For example:

    • Jacl:
      $AdminConfig create LibraryRef $classLoad1 {{libraryName MyshareLibrary}}
      
    • Jython:
      print AdminConfig.create('LibraryRef', classLoad1, [['libraryName', 'MyshareLibrary']])
      

    Element Description
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object representing the WAS configuration
    create n AdminConfig command
    LibraryRef n AdminConfig object
    classLoad1 Evaluate to the ID of class loader specified in step number 4
    libraryName Attribute
    MyshareLibrary Value of the libraryName attribute
    Example output:

    (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#LibraryRef_1)
    

  7. Save the configuration changes.
    AdminConfig.save()
    
  8. Synchronize the node.

    Use the syncActiveNode or syncNode scripts in the AdminNodeManagement script library to propagate the configuration changes to node or nodes.

    • Use the syncActiveNodes script to propagate the changes to each node in the cell:
      AdminNodeManagement.syncActiveNodes()
      

    • Use the syncNode script to propagate the changes to a specific node:
      AdminNodeManagement.syncNode("myNode")
      

  • Start the wsadmin scripting client
  • Create shared libraries
  • Associating shared libraries with applications or modules
  • wsadmin AdminConfig
  • Configure a shared library using scripting
  • Resource configuration scripts
  • Commands for the AdminConfig object