3
votes

Please find the below code

runningServer1 = AdminControl.completeObjectName("type=Server,node=nodename,process=processname,*")
print "server running --->",runningServer1
if len(runningServer1) == 0:

    print "Error: Server not running...",process_name

The ouput is that the

"Error : Server not running..."

though my server is running and I am able to launch the application. And also the runningServer1 variable is not printed , why is it that I am unable to get an object for the server?

More information about my question which I posted in IBM forums below

https://www.ibm.com/developerworks/forums/thread.jspa?threadID=374216

1
Are the node and process names right? What is returned by queryNames("type=Server,*")? Are you running base or ND?Brett Kail
@bkail I am a newbie to python and I think we dont have a node agent and hence its as standalone server.Also I got to know that We cannot start or stop through jython scripts if ther is no node agent.But What I dint understand is that Wy the server shows as not running even though everythngs right .crackerplace
I am able to launch the Apps.The only running server as hsown is server1 which is the default one.crackerplace

1 Answers

1
votes

bkail is on the right track. You need to make sure your search string is correct. Use:

print AdminControl.queryNames('type=Server,*')

in an interactive wsadmin.sh session to list all of the running servers in your cell. Then use:

'type=Server,name=JVM_NAME,*'

for your search string. Where JVM_NAME is determined from the ouput from the queryNames you just ran.

Also, I'd avoid AdminControl.completeObjectName. I'm not sure of the implications, but this snippet from the doc leads me to think it may not do what you think it does:

Use the completeObjectName command to create a string representation of a complete ObjectName value that is based on a fragment. This command does not communicate with the server to find a matching ObjectName value. If the system finds several MBeans that match the fragment, the command returns the first one.

Here's how IBM does it in WAS_ROOT/scriptLibraries/servers/V70/AdminServerManagement.py (lines 814-815):

runningServer = AdminControl.queryNames("type=Server,node="+nodeName+",name="+serverName+",*")
if (len(runningServer) > 0 and AdminControl.getAttribute(runningServer, "state") == "STARTED"):
    ...

In my experience, AdminControl.queryNames will only return running servers. So, depending on your needs just checking the return value of len(runningServer) may be sufficient. Also, in true IBM fashion there is nothing in the docs that list the possible return values of AdminControl.getAttribute(runningServer, "state"). I've only been able to find references to 'STARTED'.