Tuesday, July 2, 2013

Start applications using wsadmin websphere

from java.lang import Exception as JavaException
myapps=AdminApp.list().splitlines()
for app in myapps:
  x=AdminControl.queryNames('type=Application,name='+app+',*')
  if (len(x) == 0):
    print app 'Application is not started'
    mycell=AdminControl.getCell()
    mynode=AdminControl.getNode()
    mserver=AdminControl.queryNames('node='+mynode+',type=Server,*')
    myserver=AdminControl.getAttribute(mserver,'name')
    appManager = AdminControl.queryNames('type=ApplicationManager,cell='+mycell+',node='+mynode+',process='+myserver+',*')
    try:
     AdminControl.invoke(appManager,'startApplication',app)
    except JavaException,target:
     "WSADMIN EXCEPTION",target 
      
 
Place these lines in jython file named appstatus.py and execute wsadmin using the below option:
 
Go to $WAS_PROFILE/bin and issue the below command
./wsadmin.sh -lang jython -f appstatus.py

3 comments:

  1. Helpful, thank you.
    One small mistake though (I think).

    Shouldn't the line
    mynode=AdminControl.getCell()

    not read
    mynode=AdminControl.getNode() ???

    ReplyDelete
  2. Thanks for pointing the spelling mistake.Its corrected now.

    ReplyDelete

Your suggestions please