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
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21218750