Tuesday, 13 January 2015

WebSphere Application Server administration - being strung along by Jython

So I spent about 20 minutes wondering why I kept getting this exception: -

WASX7015E: Exception running command: "AdminTask.manageWMQ(ra, '[-nativePath /opt/ibm/mqm/usr/mqm/java/lib64 -disableWMQ false ]')"; exception information:
com.ibm.ws.scripting.ScriptingException: com.ibm.ws.scripting.ScriptingException: WASX7025E: Error found in String ""; cannot create ObjectName.


when running this Jython script: -

cellID = AdminControl.getCell()
clusterName = sys.argv[0]

clusterName = "AppCluster"
ra=AdminConfig.getid("/Cell/'+cellID+'/ServerCluster/'+clusterName+'/J2CResourceAdapter:WebSphere MQ Resource Adapter/")

AdminTask.manageWMQ(ra, '[-nativePath /opt/ibm/mqm/usr/mqm/java/lib64 -disableWMQ false ]')

AdminConfig.save()
AdminNodeManagement.syncActiveNodes()


the purpose of which is to set the native path for a J2C Resource Adapter that's scoped to my IBM Business Process Manager cluster ( AppCluster ).

This follows on from an earlier blog post: -


Did I fix the problem ?

Well, yes, eventually, via trial and error.

I realised that this line: -

ra=AdminConfig.getid("/Cell/'+cellID+'/ServerCluster/'+clusterName+'/J2CResourceAdapter:WebSphere MQ Resource Adapter/")

was actually doing nothing of use - the AdminConfig.getid() operation wasn't returning anything, meaning that the ra variable was null.

I looked again at the offending line: -

ra=AdminConfig.getid("/Cell/'+cellID+'/ServerCluster/'+clusterName+'/J2CResourceAdapter:WebSphere MQ Resource Adapter/")

and, after a while, noticed the obvious issue ...... can you see what it is ?

ra=AdminConfig.getid("/Cell/'+cellID+'/ServerCluster/'+clusterName+'/J2CResourceAdapter:WebSphere MQ Resource Adapter/")

Yes, I was mixing my quotation symbols - I was using this ( " ) and this ( ' ).

Once I fixed the script to this: -

AdminConfig.getid("/Cell/"+cellID+"/ServerCluster/"+clusterName+"/J2CResourceAdapter:WebSphere MQ Resource Adapter/")

it worked a treat.

No comments: