jython script for modify the contextroot of a running app in WAS 6.1

WAS
WAS used Ask the Experts™
on
i have trouble modifying the contextroot of a running application port-logic, below is the info and errors iam getting, please provide me with correct jython command to modify just the
context root of a running, mine is WAS6.1.0.21
wsadmin>AdminApp.edit('port-logic', ["-options"])
WASX7015E: Exception running command: "AdminApp.edit('lossb-slm', ["-options"])"; exception information:
 com.ibm.ws.scripting.ScriptingException: WASX7107E: Invalid options specified: "[options]"; valid options are:
MapModulesToServers
MapWebModToVH
CtxRootForWebMod
MapSharedLibForMod
JSPReloadForWebMod
distributeApp
nodistributeApp
useMetaDataFromBinary
nouseMetaDataFromBinary
createMBeansForResources
nocreateMBeansForResources
reloadEnabled
noreloadEnabled
allowDispatchRemoteInclude
noallowDispatchRemoteInclude
allowServiceRemoteInclude
noallowServiceRemoteInclude
verbose
installed.ear.destination
reloadInterval
validateinstall
filepermission
buildVersion
filepermission
installed.ear.destination

wsadmin>print AdminApp.view("port-logic", "-CtxRootForWebMod")


CtxRootForWebMod: Edit the Context root of web module

Context root defined in the deployment descriptor can be edited.

Web module:  port-logic.war
URI:  port-logic.war,WEB-INF/web.xml
ContextRoot:  krishna


wsadmin>


wsadmin>AdminApp.edit ( 'port-logic', ['-CtxRootForWebMod', 'Govind'])
WASX7015E: Exception running command: "AdminApp.edit ( 'port-logic', ['-CtxRootForWebMod', 'govind'])"; exception information:
 java.lang.ClassCastException: java.lang.ClassCastException: java.lang.String incompatible with java.util.List

wsadmin>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
WASIT Analyst

Author

Commented:
Hi HonorGod,

How are you..not sure this ticket same into your radar, can you please help me with question
Software Engineer
Commented:
Not too bad.  I hope that you are doing well.

Is this a 1 time thing, or do you need a general script?

For a 1 time thing, you can:

- Use print AdminApp.view( applicationName, '-CtxRootForWebMod' )
   to display the current section in question
- Then use AdminApp.edit( applicationName, [ '-CtxRootForWebMod', [ [ WebModuleInfo, URI, newCtxtRoot ] ] ] )

- Then, use the print AdminApp.view( applicationName, '-CtxRootForWebMod' )
   to verify the changes, and if they are right
- Use AdminConfig.save()

wsadmin>print AdminApp.view( 'DefaultApplication', '-CtxRootForWebMod' )


CtxRootForWebMod: Edit the Context root of web module

Context root defined in the deployment descriptor can be edited.

Web module:  Default Web Application
URI:  DefaultWebApplication.war,WEB-INF/web.xml
Context Root:  /


wsadmin>AdminApp.edit( 'DefaultApplication', [ '-CtxRootForWebMod', [ [ 'Default Web Application', 'DefaultWebApplication.war,WEB-INF/web.xml', '/Bob' ] ] ] )
''
wsadmin>print AdminApp.view( 'DefaultApplication', '-CtxRootForWebMod' )


CtxRootForWebMod: Edit the Context root of web module

Context root defined in the deployment descriptor can be edited.

Web module:  Default Web Application
URI:  DefaultWebApplication.war,WEB-INF/web.xml
Context Root:  /Bob


wsadmin>

Open in new window

WASIT Analyst

Author

Commented:
that worked really good. one more thing, is there a way to output script output to a file, this is how i run the jython script
sudo -u web ./wsadmin.sh -lang jython -f ~/scripts/change_contextroot.py
HonorGodSoftware Engineer

Commented:
Sure.  Just add a normal output redirect...

Thanks for the grade & points.

Good luck and have a great day.
sudo -u web ./wsadmin.sh -lang jython -f ~/scripts/change_contextroot.py > /tmp/change_contextroot.output

Open in new window

Hi HonorGod,

I'm in same situation here, but using jacl on WAS v8.5.5.2 Base version.
I'm trying to deploy DefaultApplication.ear file through a script. I downloaded the WAS Samples script and doing the deploy.
I'm using the attached the below script to deploy ear file successfully.

I want to change the default ContextRoot and I want to map the modules to both the AppServer and WebServer using jacl wsadmin in the app deploy.
I tried to add MapModulesToServers but i always get error.

Can you please tell me what arguments i need to pass in the below script to deploy the application, change the context root to /samples and MapModules to both appservers and webservers.
In simple, is all three possible in $AdminApp install {...................}

Thanks,
ST

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial