#Created 09:14 10-October-2011
#Created by Steve Robinson
#References: WebSphere Application Server Administration Using Jython
#Purpose - Show a simple example of how to catch WAS being down ie wsadmin cannot connect to the WAS AdminTask object to run jython script to get the cell name
################# SAMPLE ERROR ######################
#f:\script\jython>"C:\PROGRAM FILES\IBM\WebSphere\AppServer\profiles\AppSrv01"\bin\wsadmin.bat -lang jython -f f:\script\jython\schedule_mbean.py
#WASX7023E: Error creating "SOAP" connection to host "localhost"; exception information:
#com.ibm.websphere.management.exception.ConnectorNotAvailableException: com.ibm.websphere.management.exception.Co#nnectorNotAvailableException: ADMC0016E:
#The system cannot create a SOAP connector to connect to host localhost at port 8880.
#WASX7213I: This scripting client is not connected to a server process; please refer to the log file
#c:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\wsadmin.traceout for additional information.
#WASX8011W: AdminTask object is not available.
#WASX7017E: Exception received while running file "f:\script\jython\schedule_mbean.py"; exception information: com.ibm.ws.scripting.ScriptingException: AdminControl service not available
###################################################
#MAIN
print "entering main"
try :
#Get cell name
cellName = AdminControl.getCell()
print "Cell name = " + cellName
#Get cell id
cells = AdminConfig.list("Cell" )
print "cell variable contains: "+ cells
except :
print "Entering exception catch"
notavail = 'AdminControl service not available'
( kind, value ) = sys.exc_info()[ :2 ]
( kind, value ) = str( kind ), str( value )
print "kind = " + kind
print "value = " + value
if value.endswith( notavail ) :
print "System modules"
print 50 * "*"
print "sys.modules.keys()="
print sys.modules.keys()
print 50 * "*"
print "Local variables"
print 50 * "*"
print "locals()="
print locals()
print 50 * "*"
print '"%(notavail)s": wsadmin isn\'t connected to a server.' % locals()
if 'AdminTask' in sys.modules.keys() :
print '%(funName)s "%(notavail)s": WAS wsadmin started with "-conntype none"?' % locals()
elif value.find( 'WASX7025E' ) > -1 :
print '%(funName)s: Invalid mbean identifier: %(mbean)s' % locals()
else :
print 'Exception type: ' + kind
print 'Exception value: ' + value
Result:
F:\script\jython>"C:\PROGRAM FILES\IBM\WebSphere\AppServer\profiles\AppSrv01"\bin\wsadmin.bat -lang jython -f
WASX7023E: Error creating "SOAP" connection to host "localhost"; exception information: com.ibm.websphere.mana
nnectorNotAvailableException: ADMC0016E: The system cannot create a SOAP connector to connect to host localhos
WASX7213I: This scripting client is not connected to a server process; please refer to the log file c:\Program
rmation.
WASX8011W: AdminTask object is not available.
entering main
Entering exception catch
kind = com.ibm.ws.scripting.ScriptingException
value = com.ibm.ws.scripting.ScriptingException: AdminControl service not available
System modules
**************************************************
sys.modules.keys()=
['time', 'java', '__builtin__', 'exceptions', 'sys']
**************************************************
Local variables
**************************************************
locals()=
{'AdminConfig': com.ibm.ws.scripting.AdminConfigClient@246e246e, '__doc__': None, 'flag': '', 'Help': com.ibm.
Mechanism at 1226590492>, 'getSecurityAdminMbean': <function getSecurityAdminMbean at 1206929392>, 'sleep': <j
r.coordinator.impl.jmx.ProxyScriptExtension@49f049f0, 'LTPA_LDAPSecurityOn': <function LTPA_LDAPSecurityOn at
1206142948>, 'ltpaId': '', 'forceSync': <function forceSync at 1229736268>, 'ldapPort': '', 'nodeName': '', '
atEnv': <function whatEnv at 1203783616>, 'AdminControl': com.ibm.ws.scripting.AdminControlClient@48124812, 'd
SecId at 1204570060>, 'notavail': 'AdminControl service not available', 'sys': sys module, 'doGlobalSecurityDi
.bsf.util.BSFFunctions@5b785b78, 'exportLTPAKey': <function exportLTPAKey at 1225804048>, 'securityoff': <func
yOff': <function LTPA_LDAPSecurityOff at 1231964526>, 'java': <java package java at 1657823952>, 'cellName': '
on getLTPAId at 1205356504>, 'lineSeparator': '\r\n', 'generateLTPAKeys': <function generateLTPAKeys at 122501
checkuserpw at 1271417800>, 'ldapUserRegistryId': '', 'securityon': <function securityon at 1279806536>, 'ldap
**************************************************
"AdminControl service not available": wsadmin isn't connected to a server.