Updating installed applications using the wsadmin scripting tool

Use the wsadmin tool and scripting to update installed applications on an application server.

About this task

Both the update command and the updateinteractive command support a set of options. You can also obtain a list of supported options for an Enterprise Archive (EAR) file using the options command, for example:

Using Jacl:
$AdminApp options
Using Jython:
print 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.

Attention: 如果應用程式在執行中,變更應用程式設定會使應用程式重新啟動。 在獨立式伺服器上,會在儲存變更之後重新啟動應用程式。 在多重伺服器產品上,會在儲存變更之後重新啟動應用程式,在安裝應用程式的節點上,檔案會同步化。 如果要控制多重伺服器產品上的同步化時機,請在「主控台」喜好設定頁面上取消選取與節點同步變更

Perform the following steps to update an application:

Procedure

  1. 啟動 wsadmin Scripting 工具。
  2. Update the installed application using one of the following options.
    • The following command updates a single file in a deployed application:
      • Using Jacl:

        [AIX Solaris HP-UX Linux Windows]
        $AdminApp update app1 file {-operation update -contents c:/apps/app1/my.xml 
         -contenturi app1.jar/my.xml}
        [z/OS]
        $AdminApp update app1 file {-operation update -contents /apps/app1/my.xml 
         -contenturi app1.jar/my.xml}
        [IBM i]
        $AdminApp update app1 file {-operation update -contents 
         /home/myProfile/apps/app1/my.xml -contenturi app1.jar/my.xml}
      • Using Jython string:

        [AIX Solaris HP-UX Linux Windows]
        AdminApp.update('app1', 'file', '[-operation update -contents c:/apps/app1/my.xml  
         -contenturi app1.jar/my.xml]')
        [z/OS]
        AdminApp.update('app1', 'file', '[-operation update -contents /apps/app1/my.xml  
         -contenturi app1.jar/my.xml]')
        [IBM i]
        AdminApp.update('app1', 'file', '[-operation update -contents /home/myProfile/ 
         apps/app1/my.xml -contenturi app1.jar/my.xml]')
      • Using Jython list:

        [AIX Solaris HP-UX Linux Windows]
        AdminApp.update('app1', 'file', ['-operation', 'update', '-contents', 
         'c:/apps/app1/my.xml', '-contenturi', 'app1.jar/my.xml'])
        [z/OS]
        AdminApp.update('app1', 'file', ['-operation', 'update', '-contents', 
         '/apps/app1/my.xml',  '-contenturi', 'app1.jar/my.xml'])
        [IBM i]
        AdminApp.update('app1', 'file', ['-operation', 'update', '-contents', 
         '/home/myProfile/apps/app1/my.xml', '-contenturi', 'app1.jar/my.xml'])
      Table 1. update file command elements. Run the update command to change an installed application file.
      Element Definition
      $ is a Jacl operator for substituting a variable name with its value
      AdminApp is an object that supports application objects management
      update is an AdminApp command
      app1 is the name of the application to update
      file is the content type value
      operation is an option of the update command
      update is the value of the operation option
      contents is an option of the update command
      /apps/app1/my.xml is the value of the contents option
      contenturi is an option of the update command
      app1.jar/my.xml is the 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.
      • Using Jacl:

        [AIX Solaris HP-UX Linux Windows]
        $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}}}
        [z/OS]
        $AdminApp update app1 modulefile {-operation addupdate -contents 
         /apps/app1/Increment.jar -contenturi Increment.jar -nodeployejb
         -BindJndiForEJBNonMessageBinding {{"Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc}}}
        [IBM i]
        $AdminApp update app1 modulefile {-operation addupdate -contents  
         /home/myProfile/apps/app1/Increment.jar -contenturi Increment.jar -nodeployejb
          -BindJndiForEJBNonMessageBinding {{"Increment EJB module"  Increment Increment.jar,META-INF/ejb-jar.xml Inc}}}
      • Using Jython string:

        [AIX Solaris HP-UX Linux Windows]
        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]]]')
        [z/OS]
        AdminApp.update('app1', 'modulefile', '[-operation addupdate -contents 
         /apps/app1/Increment.jar -contenturi Increment.jar -nodeployejb
         -BindJndiForEJBNonMessageBinding [["Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc]]]')
        [IBM i]
        AdminApp.update('app1', 'modulefile', '[-operation addupdate -contents 
         /home/myProfile/apps/app1/Increment.jar -contenturi Increment.jar -nodeployejb
         -BindJndiForEJBNonMessageBinding [["Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc]]]')
      • Using Jython list:

        [AIX Solaris HP-UX Linux Windows]
        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])
        [z/OS]
        bindJndiForEJBValue = [["Increment EJB module", "Increment", "Increment.jar,META-INF/ejb-jar.xml", 
        "Inc"]]  AdminApp.update('app1', 'modulefile', ['-operation', 'addupdate', '-contents', 
         '/apps/app1/Increment.jar', '-contenturi','Increment.jar' '-nodeployejb', `-BindJndiForEJBNonMessageBinding', 
         bindJndiForEJBValue])
        [IBM i]
        bindJndiForEJBValue = [["Increment EJB module", "Increment", "Increment.jar,META-INF/ejb-jar.xml", 
        "Inc"]]  AdminApp.update('app1', 'modulefile', ['-operation', 'addupdate', '-contents', 
         '/home/myProfile/apps/app1/Increment.jar', '-contenturi','Increment.jar'
         '-nodeployejb', `-BindJndiForEJBNonMessageBinding', bindJndiForEJBValue])
      Table 2. update modulefile command elements. Run the update command to change an installed module file.
      Element Definition
      $ is a Jacl operator for substituting a variable name with its value
      AdminApp is an object that supports application objects management
      update is an AdminApp command
      app1 is the name of the application to update
      modulefile is the content type value
      operation is an option of the update command
      addupdate is the value of the operation option
      contents is an option of the update command
      /apps/app1/Increment.jar is the value of the contents option
      contenturi is an option of the update command
      Increment.jar is the value of the contenturi option
      nodeployejb is an option of the update command
      BindJndiForEJBNonMessageBinding is an option of the update command
      "Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc is the value of the BindJndiForEJBNonMessageBinding option. The value of this option is defined in your application configuration. To determine the value of this option, use the following Jython or Jacl command:
      Using Jython:
      AdminApp.view('myAppName')
      Using Jacl:
      $AdminApp view myAppName
      bindJndiForEJBValue is a Jython variable that contains the value of the BindJndiForEJBNonMessageBinding option
    • The following command uses a partial application to update a deployed application:
      • Using Jacl:

        [AIX Solaris HP-UX Linux Windows]
        $AdminApp update app1 partialapp {-contents c:/apps/app1/app1Partial.zip}
        [z/OS]
        $AdminApp update app1 partialapp {-contents /apps/app1/app1Partial.zip}
        [IBM i]
        $AdminApp update app1 partialapp {-contents /home/myProfile/apps/app1/app1Partial.zip}
      • Using Jython string:

        [AIX Solaris HP-UX Linux Windows]
        AdminApp.update('app1', 'partialapp', '[-contents 
         c:/apps/app1/app1Partial.zip]')
        [z/OS]
        AdminApp.update('app1', 'partialapp', '[-contents /apps/app1/app1Partial.zip]')
        [IBM i]
        AdminApp.update('app1', 'partialapp', '[-contents
         /home/myProfile/apps/app1/app1Partial.zip]')
      • Using Jython list:

        [AIX Solaris HP-UX Linux Windows]
        AdminApp.update('app1', 'partialapp', ['-contents', 
         'c:/apps/app1/app1Partial.zip'])
        [z/OS]
        AdminApp.update('app1', 'partialapp', ['-contents', 
         '/apps/app1/app1Partial.zip'])
        [IBM i]
        AdminApp.update('app1', 'partialapp', ['-contents', 
         '/home/myProfile/apps/app1/app1Partial.zip'])
      Table 3. update partialapp command elements. Run the update command to change part of an installed application.
      Element Definition
      $ is a Jacl operator for substituting a variable name with its value
      AdminApp is an object that supports application objects management
      update is an AdminApp command
      app1 is the name of the application to update
      partialapp is the content type value
      contents is an option of the update command
      /apps/app1/app1Partial.zip is the value of the contents option
    • Update the entire deployed application.

      如果要使用現有的接聽器埠,而不使用或建立新的啟動規格,請判斷 EJB JAR 版本是否早於 2.1 版。 當您指定 -usedefaultbindings 選項來部署應用程式時,系統會自動建立及使用啟動規格。 如果啟動規格存在,系統會忽略接聽器埠,改用啟動規格。 如果要利用已定義的接聽器埠來部署 EJB JAR 2.1 版或以上的應用程式,而不用新的啟動規格,請將相關設定檔的 properties 目錄之下 wsadmin.properties 檔中的 com.ibm.websphere.management.application.dfltbndng.mdb.preferexisting 系統內容設為 true

      • Using Jacl:

        [AIX Solaris HP-UX Linux Windows]
        $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}}}
        [z/OS]
        $AdminApp update app1 app {-operation update -contents /apps/app1/newApp1.jar 
         -usedefaultbindings -nodeployejb -BindJndiForEJBNonMessageBinding {{"Increment EJB module" Increment 
         Increment.jar,META-INF/ejb-jar.xml Inc}}}
        [IBM i]
        $AdminApp update app1 app {-operation update -contents 
         /home/myProfile/apps/app1/newApp1.jar -usedefaultbindings -nodeployejb
         -BindJndiForEJBNonMessageBinding {{"Increment EJB module" 
         Increment Increment.jar,META-INF/ejb-jar.xml Inc}}}
      • Using Jython string:

        [AIX Solaris HP-UX Linux Windows]
        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]]]')
        [z/OS]
        AdminApp.update('app1', 'app', '[-operation update -contents 
         /apps/app1/newApp1.ear -usedefaultbindings -nodeployejb
         -BindJndiForEJBNonMessageBinding [["Increment EJB module" Increment 
         Increment.jar,META-INF/ejb-jar.xml Inc]]]')
        [IBM i]
        AdminApp.update('app1', 'app', '[-operation update -contents 
         /home/myProfile/apps/app1/ newApp1.ear -usedefaultbindings -nodeployejb -BindJndiForEJBNonMessageBinding [["Increment EJB module" 
         Increment Increment.jar,META-INF/ejb-jar.xml Inc]]]')
      • Using Jython list:

        [AIX Solaris HP-UX Linux Windows]
        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]) 
         
        [z/OS]
        bindJndiForEJBValue = [["Increment EJB module", "Increment", "Increment.jar,META-INF/ejb-jar.xml", 
        "Inc"]]  AdminApp.update('app1', 'app', ['-operation', 'update', '-contents', 
         '/apps/app1/NewApp1.ear', '-usedefaultbindings', '-nodeployejb', `-BindJndiForEJBNonMessageBinding', bindJndiForEJBValue]) 
        [IBM i]
        bindJndiForEJBValue = [["Increment EJB module", "Increment", "Increment.jar,META-INF/ejb-jar.xml", 
        "Inc"]]  AdminApp.update('app1', 'app', ['-operation', 'update', '-contents', 
         '/apps/app1/NewApp1.ear', '-usedefaultbindings', '-nodeployejb', `-BindJndiForEJBNonMessageBinding', bindJndiForEJBValue]) 
      Table 4. update app command elements. Run the update command to change an installed application.
      Element Definition
      $ is a Jacl operator for substituting a variable name with its value
      AdminApp is an object that supports application objects management
      update is an AdminApp command
      app1 is the name of the application to update
      app is the content type value
      operation is an option of the update command
      update is the value of the operation option
      contents is an option of the update command
      /apps/app1/newApp1.ear is the value of the contents option
      usedefaultbindings is an option of the update command
      nodeployejb is an option of the update command
      BindJndiForEJBNonMessageBinding is an option of the update command
      "Increment EJB module" Increment Increment.jar,META-INF/ejb-jar.xml Inc is the value of the BindJndiForEJBNonMessageBinding option. The value of this option is defined in your application configuration. To determine the value of this option, use the following Jython or Jacl command:
      Using Jython:
      AdminApp.view('myAppName')
      Using Jacl:
      $AdminApp view myAppName
      bindJndiForEJBValue is a Jython variable containing the value of the BindJndiForEJBNonMessageBinding option
  3. Save the configuration changes.
    請利用下列指令範例來儲存您的配置變更:
    AdminConfig.save()
  4. In a network deployment environment only, synchronize the node.
    請利用 AdminNodeManagement Script 程式庫中的 syncActiveNode 或 syncNode Script,將配置變更傳播給節點。
    • 利用 syncActiveNodes Script,依照下列範例所示,將變更傳播給 Cell 中的每個節點:
      AdminNodeManagement.syncActiveNodes()
    • 利用 syncNode Script,依照下列範例所示,將變更傳播給特定的節點:
      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. 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 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:

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..."
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

指出主題類型的圖示 作業主題



時間戳記圖示 前次更新: July 9, 2016 11:19
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_updatingapp
檔名:txml_updatingapp.html