Installing enterprise applications using wsadmin scripting

Use the AdminApp object or the AdminApplication script library to install an application to the application server run time. You can install an enterprise archive file (EAR), web application archive (WAR) file, servlet archive (SAR), or Java™ archive (JAR) file.

Before you begin

On a network deployment installation, verify that the deployment manager is running before you install an application. Use the startManager command utility to start the deployment manager.

There are two ways to complete this task. Complete the steps in this topic to use the AdminApp object to install enterprise applications. Alternatively, you can use the scripts in the AdminApplication script library to install, uninstall, and administer your application configurations.
Avoid trouble: During an Enterprise application deployment, it might be necessary to scan the application binary files for annotations that were introduced by Java EE 5 or later. An application might not deploy if it is compiled by using a Java SDK level that is higher than the Java SDK level of a deployment manager. The deployment manager needs to be either at the same Java SDK level or at a higher Java SDK level than the application.

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

About this task

Use this topic to install an application from an enterprise archive file (EAR), a web application archive (WAR) file, a servlet archive (SAR), or a Java archive (JAR) file. The archive file must end in .ear, .jar, .sar or .war for the wsadmin tool to complete the installation. The wsadmin tool uses these extensions to determine the archive type. The wsadmin tool automatically wraps WAR and JAR files as an EAR file.

Best practice: Use the most recent product version of the wsadmin tool when installing applications to mixed-version environments to ensure that the most recent wsadmin options and commands are available.

Procedure

  1. Start the wsadmin scripting tool.
  2. Determine which options to use to install the application in your configuration.

    For example, if your configuration consists of a node, a cell, and a server, you can specify that information when you enter the install command. Review the list of valid options for the install and installinteractive commands in the Options for the AdminApp object install, installInteractive, edit, editInteractive, update, and updateInteractive commands using wsadmin scripting topic to locate the correct syntax for the -node, -cell, and -server options. For this configuration, use the following command examples:

    Using Jython:
    AdminApp.install('location_of_ear.ear','[-node nodeName -cell cellName -server serverName]')
    Using Jacl:
    $AdminApp install "location_of_ear.ear" {-node nodeName -cell cellName -server serverName}

    You can also obtain a list of supported options for an enterprise archive (EAR) file using the options command, for example:

    Using Jython:
    print AdminApp.options()
    Using Jacl:
    $AdminApp options

    You can set or update a configuration value using options in batch mode. To identify which configuration object is to be set or updated, the values of read only fields are used to find the corresponding configuration object. All the values of read only fields have to match with an existing configuration object, otherwise the command fails.

    You can use pattern matching to simplify the task of supplying required values for certain complex options. Pattern matching only applies to fields that are required or read only.

  3. Choose to use the install or installInteractive command to install the application.

    You can install the application in batch mode, using the install command, or you can install the application in interactive mode using the installinteractive command. Interactive mode prompts you through a series of tasks to provide information. Both the install command and the installinteractive command support the set of options you chose to use for your installation in the previous step.

  4. Install the application.
    For this example, only the -server option is used with the install command, where the value of the -server option is serv2. Customize your install or installinteractive command with on the options you chose based on your configuration.
    • Using the install command to install the application in batch mode:
      • For a network deployment installation only, the following command uses the EAR file and the command option information to install the application on a cluster:
        • Using Jython string:

          [AIX Solaris HP-UX Linux Windows]
          AdminApp.install('c:/MyStuff/application1.ear', '[-cluster cluster1]')
          [z/OS]
          AdminApp.install('MyStuff/application1.ear', '[-cluster cluster1]')
          [IBM i]
          AdminApp.install('/home/myProfile/MyStuff/application1.ear', '[-cluster cluster1]')
        • Using Jython list:

          [AIX Solaris HP-UX Linux Windows]
          AdminApp.install('c:/MyStuff/application1.ear', ['-cluster', 'cluster1'])
          [z/OS]
          AdminApp.install('MyStuff/application1.ear', ['-cluster', 'cluster1'])
          [IBM i]
          AdminApp.install('/home/myProfile/MyStuff/application1.ear', ['-cluster', 'cluster1'])
        • Using Jacl:

          [AIX Solaris HP-UX Linux Windows]
          $AdminApp install "c:/MyStuff/application1.ear" {-cluster cluster1}
          [z/OS]
          $AdminApp install "MyStuff/application1.ear" {-cluster cluster1}
          [IBM i]
          $AdminApp install "/home/myProfile/MyStuff/application1.ear" {-cluster cluster1}
        Table 1. install cluster command elements . Run the install command with the -cluster option.
        Element Description
        $ is a Jacl operator for substituting a variable name with its value
        AdminApp is an object allowing application objects to be managed
        install is an AdminApp command
        MyStuff/application1.ear is the name of the application to install
        cluster is an installation option
        cluster1 the value of the cluster option which will be cluster name
    • Use the installInteractive command to install the application using interactive mode. The following command changes the application information by prompting you through a series of installation tasks:
      • Using Jython:

        [AIX Solaris HP-UX Linux Windows]
        AdminApp.installInteractive('c:/MyStuff/application1.ear')
        [z/OS]
        AdminApp.installInteractive('MyStuff/application1.ear')
        [IBM i]
        AdminApp.installInteractive('/home/myProfile/MyStuff/application1.ear')
      • Using Jacl:

        [AIX Solaris HP-UX Linux Windows]
        $AdminApp installInteractive "c:/MyStuff/application1.ear"
        [z/OS]
        $AdminApp installInteractive "MyStuff/application1.ear"
        [IBM i]
        $AdminApp installInteractive "/home/myProfile/MyStuff/application1.ear"
      Table 2. installInteractive command elements . Run the installInteractive command with the name of the application to install.
      Element Description
      $ is a Jacl operator for substituting a variable name with its value
      AdminApp is an object allowing application objects to be managed
      installInteractive is an AdminApp command
      MyStuff/application1.ear is the name of the application to install
  5. Save the configuration changes.
    Use the following command example to save your configuration changes:
    AdminConfig.save()
  6. In a network deployment environment only, synchronize the node.

What to do next

The steps in this task return a success message if the system successfully installs the application. However, the steps might complete successfully before the system extracts each binary file. In a network deployment environment, for example, binary files are extracted after node synchronization is complete. You cannot start the application until the system extracts all binary files. Use the isAppReady and getDeployStatus commands for the AdminApp object to verify that the system extracted the binary files before starting the application.

The isAppReady command returns a value of true if the system is ready to start the application, or a value of false if the system is not ready to start the application. If the system is not ready to start the application, the system might be expanding application binaries. A script that installs an application and then starts it typically would loop around a call to isAppReady until it returns a value of true before attempting to start the application.

For example, using Jython:
import time
result = AdminApp.isAppReady('application1')
while (result == "false"):
   ### Wait 5 seconds before checking again
   time.sleep(5)
   result = AdminApp.isAppReady('application1')
print("Starting application...")
Using Jacl:
set result [$AdminApp isAppReady application1]
while {$result == "false"} {
   ### Wait 5 seconds before checking again
   after 5000
   set result [$AdminApp isAppReady application1]
}
puts "Starting application..."

If the system is not ready to start the application, the system might be expanding application binaries. Use the getDeployStatus command to display additional information about the binary file expansion status, as the following examples display:

Using Jython:
print AdminApp.getDeployStatus('application1')
Using Jacl:
$AdminApp getDeployStatus application1

Running the getDeployStatus command where application1 is DefaultApplication results in status information about DefaultApplication resembling the following:

ADMA5071I: Distribution status check started for application DefaultApplication.
WebSphere:cell=myCell01,node=myNode01,distribution=unknown,expansion=unknown
ADMA5011I: The cleanup of the temp directory for application DefaultApplication is complete.
ADMA5072I: Distribution status check completed for application DefaultApplication.
WebSphere:cell=myCell01,node=myNode01,distribution=unknown,expansion=unknown