IBM Support

Using -MapModulesToServers with variables

Troubleshooting


Problem

How to use the -MapModulesToServers command with variables in wsadmin scripting to deploy an application and map specific application modules to specific servers.

Cause

To deploy an application and map modules to servers using wsadmin, use the $AdminApp command with the -MapModulesToServers option. An example in Jacl:

$AdminApp install C://myapp.ear {-MapModulesToServers {{"Default Application" default_app.war,WEB-INF/web.xml
WebSphere:cell=mycell,node=mynode,server=server1}}}

However, to do this on multiple machines, variables need to be used eliminating the need to hard-code the cellname and nodename.

Do not substitute the string "WebSphere:cell=mycell,node=mynode,server=server1"
with variables for the cellname and nodename, such as
"WebSphere:cell=$mycell,node=$mynode,server=server1" because all options specified are considered as a single string.

Substitution of variables will not happen when running the AdminApp command.

Resolving The Problem

To use variables in this case, construct a string, with all specified options. When the string is constructed, the variables are substituted, and then use this options string with the install command.

An example in Jacl, which deploys the WAR module of an application to both server1 and a Web server:

set cellName [$AdminControl getCell]
set nodeName [$AdminControl getNode]

set appserverName "server1"
set webserverName "mywebserver"
set webserverNodeName "${webserverName}_node"

set appserver WebSphere:cell=$cellName,node=$nodeName,server=$appserverName
set webserver WebSphere:cell=$cellName,node=$webserverNodeName,server=$webserverName

set myModule [list "MyWebApp" MyWebApp.war,WEB-INF/web.xml $appserver+$webserver]
set options [list -MapModulesToServers [list $myModule]]

$AdminApp install "MyWebAppEAR.ear" $options
$AdminConfig save

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Administrative Scripting Tools (for example: wsadmin or ANT)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.1;6.0","Edition":"Base;Express;Network Deployment","Line of Business":{"code":"LOB36","label":"IBM Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}},{"Product":{"code":"SS7JFU","label":"WebSphere Application Server - Express"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":" ","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.1;6.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21218750