Update installed applications using the wsadmin scripting tool
Use the wsadmin tool and scripting to update installed applications on an application server.
Both the update command and the updateinteractive command support a set of options. We can also obtain a list of supported options for an Enterprise Archive (EAR) file using the options command, for example:
Use Jacl:
$AdminApp options
Use Jython:
print AdminApp.options()
We 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.
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.
Update an application
- Start the wsadmin scripting tool.
- Update the installed application using one of the following options.
- The following command updates a single file in a deployed application:
Use Jacl:
$AdminApp update app1 file {-operation update -contents c:/apps/app1/my.xml -contenturi app1.jar/my.xml}
- Jython string:
AdminApp.update('app1', 'file', '[-operation update -contents c:/apps/app1/my.xml -contenturi app1.jar/my.xml]')
- Jython list:
AdminApp.update('app1', 'file', ['-operation', 'update', '-contents', 'c:/apps/app1/my.xml', '-contenturi', 'app1.jar/my.xml'])
update file command elements
Element Definition $ Jacl operator for substituting a variable name with its value AdminApp object that supports application objects management update AdminApp command app1 Name of the application to update file is the content type value operation Option of the update command update Value of the operation option contents Option of the update command /apps/app1/my.xml Value of the contents option contenturi Option of the update command app1.jar/my.xml Value of the contenturi option - The following command adds a module to the deployed application, if the module does not exist. Otherwise, the existing module is updated.
Use Jacl:
$AdminApp update app1 modulefile {-operation addupdate -contents c:/apps/app1/Increment.jar -contenturi Increment.jar -nodeployejb -BindJndiForEJBNonMessageBinding {{"Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc}}}
Use Jython string:
AdminApp.update('app1', 'modulefile', '[-operation addupdate -contents c:/apps/app1/Increment.jar -contenturi Increment.jar -nodeployejb -BindJndiForEJBNonMessageBinding [["Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc]]]')
- Jython list:
bindJndiForEJBValue = [["Increment EJB module", "Increment", "Increment.jar,META-INF/ejb-jar.xml", "Inc"]] AdminApp.update('app1', 'modulefile', ['-operation', 'addupdate', '-contents', 'c:/apps/app1/Increment.jar', '-contenturi','Increment.jar' '-nodeployejb', `-BindJndiForEJBNonMessageBinding', bindJndiForEJBValue])
update modulefile command elements.
Element Definition $ Jacl operator for substituting a variable name with its value AdminApp object that supports application objects management update AdminApp command app1 Name of the application to update modulefile is the content type value operation Option of the update command addupdate Value of the operation option contents Option of the update command /apps/app1/Increment.jar Value of the contents option contenturi Option of the update command Increment.jar Value of the contenturi option nodeployejb Option of the update command BindJndiForEJBNonMessageBinding Option of the update command "Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc Value of the BindJndiForEJBNonMessageBinding option. The value of this option is defined in the application configuration. To determine the value of this option, use the following Jython or Jacl command: Use Jython:
AdminApp.view('myAppName')
Using Jacl:
$AdminApp view myAppName
bindJndiForEJBValue Jython variable containing the value of the BindJndiForEJBNonMessageBinding option - The following command uses a partial application to update a deployed application:
Use Jacl:
$AdminApp update app1 partialapp {-contents c:/apps/app1/app1Partial.zip}
- Jython string:
AdminApp.update('app1', 'partialapp', '[-contents c:/apps/app1/app1Partial.zip]')
- Jython list:
AdminApp.update('app1', 'partialapp', ['-contents', 'c:/apps/app1/app1Partial.zip'])
Element Definition $ Jacl operator for substituting a variable name with its value AdminApp object that supports application objects management update AdminApp command app1 Name of the application to update partialapp is the content type value contents Option of the update command /apps/app1/app1Partial.zip Value of the contents option - Update the entire deployed application.
To use the existing listener port instead of using or creating a new activation specification, determine whether the EJB JAR version is earlier than 2.1. The system automatically creates and uses an activation specification when we specify the -usedefaultbindings option to deploy an application. If an activation specification exists, the system ignores the listener port, and instead uses the activation specification. To deploy an application with an EJB JAR version greater than or equal to 2.1 using the defined listener ports instead of a new activation specification, set the system property...
com.ibm.websphere.management.application.dfltbndng.mdb.preferexisting
...to true in the wsadmin.properties file in the properties directory of the profile of interest.
Use Jacl:
$AdminApp update app1 app {-operation update -contents c:/apps/app1/newApp1.jar -usedefaultbindings -nodeployejb -BindJndiForEJBNonMessageBinding {{"Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc}}}
- Jython string:
AdminApp.update('app1', 'app', '[-operation update -contents c:/apps/app1/newApp1.ear -usedefaultbindings -nodeployejb -BindJndiForEJBNonMessageBinding [["Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc]]]')
- Jython list:
bindJndiForEJBValue = [["Increment EJB module", "Increment", "Increment.jar,META-INF/ejb-jar.xml", "Inc"]] AdminApp.update('app1', 'app', ['-operation', 'update', '-contents', 'c:/apps/app1/NewApp1.ear', '-usedefaultbindings', '-nodeployejb', `-BindJndiForEJBNonMessageBinding', bindJndiForEJBValue])
update app command elements
Element Definition $ Jacl operator for substituting a variable name with its value AdminApp object that supports application objects management update AdminApp command app1 Name of the application to update app is the content type value operation Option of the update command update Value of the operation option contents Option of the update command /apps/app1/newApp1.ear Value of the contents option usedefaultbindings Option of the update command nodeployejb Option of the update command BindJndiForEJBNonMessageBinding Option of the update command "Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc Value of the BindJndiForEJBNonMessageBinding option. The value of this option is defined in the application configuration. To determine the value of this option, use the following Jython or Jacl command: Use Jython:
AdminApp.view('myAppName')
Using Jacl:
$AdminApp view myAppName
bindJndiForEJBValue Jython variable containing the value of the BindJndiForEJBNonMessageBinding option
- Save the configuration changes.
AdminConfig.save()
- In a network deployment environment only, 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")
What to do next
The steps in this task return a success message if the system successfully updates 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. We cannot start the application until the system extracts all binary files. Use the isAppReady and getDeployStatus commands for the AdminApp object to verify 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 updates 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, as shown in the following example:
Use 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...")
Use 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..."
Use the getDeployStatus command to display additional information about the binary file expansion status, as the following example displays:
AdminApp.getDeployStatus('app1')
Running the getDeployStatus command where app1 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
wsadmin AdminApp Commands for the AdminApp object Options for the AdminApp object install, installInteractive, edit, editInteractive, update, and updateInteractive commands Example: Obtaining option information for AdminApp object commands