Example: Listing the modules in an installed application
Use the AdminApp object listModules command to list the modules in an installed application. For example, invoke the following command interactively in a script, or use wsadmin -c from an operating system command prompt:$AdminApp listModules DefaultApplication -server
This example produces the following output:wsadmin>$AdminApp listModules DefaultApplication -serverDefaultApplication#IncCMP11.jar+META-INF/ejb-jar.xml#WebSphere:cell=mycell,node=mynode,server=myserverDefaultApplication#DefaultWebApplication.war+WEB-INF/web.xml#WebSphere:cell=mycell,node=mynode,server=myserver
Example: Obtaining task information while installing applications
The installInteractive command of the AdminApp object prompts you through a series of tasks when you install an application. You are presented with the title of the task, a description of the task, and the current contents of the task that you can modify.
· Use the install command instead of the installInteractive command, provide updates for each task, but you must provide all of the information on the command line. The task name specifies each task and the information you need to update the task. You can treat the task information as a two-dimensional array of string data. For example:-taskname {{item1a item2a item3a} {item1b item2b item3b} ...}
This example is a linear representation of rows and columns, where {item1a item2a item3a} represents the first row, and each row for the task name has three columns.
The number and type of the columns in this list depend on the task you specify.
· Obtain information about the data needed for each task using the taskInfo command of the AdminApp object. For example, there is a task called MapWebModToVH used to map Web modules to virtual hosts. To specify this task as part of the option string on the command line, enter the following:-MapWebModToVH {{"JavaMail Sample WebApp" mtcomps.war,WEB-INF/web.xml default_host}}
Using the taskInfo command, you can see which of the items you can change for a task. Supply the columns for each row you modify, and the columns that you are not allowed to change must match one of the existing rows. In this case, taskInfo tells you that there are three items in each row, called webModule, uri, and virtualHost and the current column values for every row.
· Obtain help while creating complex installation commands, by using a feature of the installInteractive command. Install the application interactively once and specify the updates that you need. Then look for message WASX7278I in the output log for the wsadmin tool. You can cut and paste the data in this message into a script, and modify it. For example: · WASX7278I: Generated command line: install c:/websphere/appserver/installableapps/jmsample.ear {-BindJndiForEJBNonMessageBinding {{deplmtest.jar MailEJBObject deplmtest.jar,META-INF/ejb-jar.xml ejb/JMSampEJB1 }} -MapResRefToEJB {{deplmtest.jar MailEJBObject deplmtest.jar,META-INF/ejb-jar.xml mail/MailSession9 javax.mail.Session mail/DefaultMailSessionX } {"JavaMail Sample WebApp" mtcomps.war,WEB-INF/web.xml mail/MailSession9 javax.mail.Session mail/DefaultMailSessionY }} -MapWebModToVH {{"JavaMail Sample WebApp" mtcomps.war,WEB-INF/web.xml newhost }} -nopreCompileJSPs -novalidateApp -installed.ear.destination c:/mylocation -distributeApp -nouseMetaDataFromBinary}
Example: Identifying supported tasks and options for an Enterprise Archive file
The AdminApp object install command takes a set of options and tasks. The following examples use the AdminApp object to obtain a list of supported tasks and options for an Enterprise Archive (EAR) file:
· To identify supported options and tasks, use the AdminApp object options command:$AdminApp options c:/MyStuff/myapp1.ear
This command displays a list of tasks and options.
· To identify supported options only, use the following command:$AdminApp options
· To learn more about any of the tasks or options, use the AdminApp object help command. For example:$AdminApp help deployejb
Example: Configuring applications for session management using the wsadmin tool
You can use the AdminApp object to set configurations in an application. Some configuration settings are not available through the AdminApp object. This example uses the AdminConfig object to configure session manager for the application.
· Identify the deployment configuration object for the application and assign it to the deployment variable:set deployment [$AdminConfig getid /Deployment:myApp/]
Example output: myApp(cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#Deployment_1)
· Retrieve the applicaton deployment and assign it to the appDeploy variable:set appDeploy [$AdminConfig showAttribute $deployment deployedObject]
Example output: (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#ApplicationDeployment_1)
· To obtain a list of attributes you can set for session manager, use the attributes command:$AdminConfig attributes SessionManager
Example output: "accessSessionOnTimeout Boolean""allowSerializedSessionAccess Boolean""context ServiceContext@""defaultCookieSettings Cookie""enable Boolean""enableCookies Boolean""enableProtocolSwitchRewriting Boolean""enableSSLTracking Boolean""enableSecurityIntegration Boolean""enableUrlRewriting Boolean""maxWaitTime Integer""properties Property(TypedProperty)*""sessionDRSPersistence DRSSettings""sessionDatabasePersistence SessionDatabasePersistence""sessionPersistenceMode ENUM(DATABASE, DATA_REPLICATION, NONE)""tuningParams TuningParams"
· Set up the attributes for the session manager:· set attr1 [list enableSecurityIntegration true]· set attr2 [list maxWaitTime 30]· set attr3 [list sessionPersistenceMode NONE]· set attrs [list $attr1 $attr2 $attr3]· set sessionMgr [list sessionManagement $attrs]
This example sets three top level attributes in the session manager. You can modify the example to set other attributes of session manager including the nested attributes in Cookie, DRSSettings, SessionDataPersistence, and TuningParms object types. To list the attributes for those object types, use the attribute command in AdminConfig object.
Example output: sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30} {sessionPersistenceMode NONE}}
· Create the session manager for the application:$AdminConfig create ApplicationConfig $appDeploy [list $sessionMgr]
Example output: (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#ApplicationConfig_1)
· Save the changes with the following command:$AdminConfig save
Example: Configuring applications for session management in Web modules using the wsadmin tool
You can use the AdminApp object to set configurations in an application. Some configuration settings are not available through the AdminApp object. This example uses the AdminConfig object to configure session manager for Web module in the application.
· Identify the deployment configuration object for the application and assign it to the deployment variable:set deployment [$AdminConfig getid /Deployment:myApp/]
Example output: myApp(cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#Deployment_1)
· Get all the modules in the application and assign it to the modules variable:· set appDeploy [$AdminConfig showAttribute $deployments deployedObject]set modules [lindex [$AdminConfig showAttribute $appDeploy modules] 0]
Example output: (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#WebModuleDeployment_1)(cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#EJBModuleDeployment_1)(cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#WebModuleDeployment_2)
· To obtain a list of attributes you can set for session manager, use the attributes command.:$AdminConfig attributes SessionManager
Example output: "accessSessionOnTimeout Boolean""allowSerializedSessionAccess Boolean""context ServiceContext@""defaultCookieSettings Cookie""enable Boolean""enableCookies Boolean""enableProtocolSwitchRewriting Boolean""enableSSLTracking Boolean""enableSecurityIntegration Boolean""enableUrlRewriting Boolean""maxWaitTime Integer""properties Property(TypedProperty)*""sessionDRSPersistence DRSSettings""sessionDatabasePersistence SessionDatabasePersistence""sessionPersistenceMode ENUM(DATABASE, DATA_REPLICATION, NONE)""tuningParams TuningParams"
· Set up the attributes for session manager:· set attr1 [list enableSecurityIntegration true]· set attr2 [list maxWaitTime 30]· set attr3 [list sessionPersistenceMode NONE]· set attr4 [list enabled true]· set attrs [list $attr1 $attr2 $attr3 $attr4]set sessionMgr [list sessionManagement $attrs]
This example sets four top level attributes in the session manager. You can modify the example to set other attributes in the seesion manager including the nested attributes in Cookie, DRSSettings, SessionDataPersistence, and TuningParms object types. To list the attributes for those object types, use the attribute command in AdminConfig object.
Example output: sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30} {sessionPersistenceMode NONE} {enabled true}}
· Set up the attributes for Web module:· set nameAttr [list name myWebModuleConfig]· set descAttr [list description "Web Module config post create"]set webAttrs [list $nameAttr $descAttr $sessionMgr]
Example output: {name myWebModuleConfig} {description {Web Module config post create}} {sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30} {sessionPersistenceMode NONE} {enabled true}}}
· Create the session manager for each Web module in the application:· foreach module $modules {· if ([regexp WebModuleDeployment $module] == 1} {· $AdminConfig create WebModuleConfig $module $webAttrs· }· }
You can modify this example to set other attributes of session manager in Web module configuration.
Example output: myWebModuleConfig(cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#WebModuleConfiguration_1)
· Save the changes with the following command:$AdminConfig save
Example: Exporting applications using the wsadmin tool
Exporting applications enables you to back them up and preserve their binding information. You can export your applications before you update installed applications or before you migrate to a different version of the WebSphere Application Server product.
· Export an enterprise application to a location of your choice, for example: $AdminApp export app1 C:/mystuff/exported.ear
where app1 is the name of the application that will be exported and C:/mystuff/exported.ear is the name of the file where the exported application will be stored.
· Export Data Definition Language (DDL) files in the enterprise bean module of an application to a destination directory, for example:$AdminApp exportDDL app1 C:/mystuffwhere app1 is the name of the application whose DDL files will be exported and C:/mystuff is the name of the directory where the DDL files export from the application.
Example: Configuring a shared library for an application
You can use the AdminApp object to set certain configurations in the application. This example uses the AdminConfig object to configure a shared library for an application.
· Identify the shared library and assign it to the library variable.
· To create a new shared library, perform the following steps:
1. Idenitfy the node and assign it to a variable, for example:set node [$AdminConfig getid /Cell:mycell/Node:mynode/]
Example output:mynode(cells/mycell/nodes/mynode:node.xml#Node_1)
2. Create the shared library in the node, for example:set library [$AdminConfig create Library $node {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}]
Example output:MySharedLibrary(cells/mycell/nodes/mynode:libraries.xml#Library_1)
This example creates a new shared library in the node scope. You can modify it to use the cell or server scope.
· To use an existing shared library, issue the following command:set library [$AdminConfig getid /Library:mySharedLibrary/]
Example output:MySharedLibrary(cells/mycell/nodes/mynode:libraries.xml#Library_1)
· Identify the deployment configuration object for the application and assign it to the deployment variable:set deployment [$AdminConfig getid /Deployment:myApp/]
Example output: myApp(cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#Deployment_1)
· Retrieve the applicaton deployment and assign it to the appDeploy variable:set appDeploy [$AdminConfig showAttribute $deployment deployedObject]
Example output: (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#ApplicationDeployment_1)
· Idenitfy the class loader in the application deployment and assign it to the classLoader variable:set classLoader [$AdminConfig showAttribute $appDeploy classloader]
Example output: (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#Classloader_1)
· Associate the shared library in the application through the class loader:$AdminConfig create LibraryRef $classLoader {{libraryName MyshareLibrary} {sharedClassloader true}}
Example output: (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#LibraryRef_1)
· Save the changes:$AdminConfig save