I'm trying to write a stand alone jython JMX client to monitor WebSphere Application Server. It connects to the DMGR using SOAP and SSL.
The code works when running it w/ WSADMIN, but fails when trying to run it as a stand alone jython client. This makes me believe the code is correct and that I'm missing a JAR or configuration file when trying to run it as a stand alone client. Also, this works w/ SSL disabled.
I have the following questions:
- How can I establish the connection with security enabled (so with SSL)?
- How can I make my client run from another machine? (which jars are needed?)
WAS Version: 7.0.0.21 ND on Solaris
import java.util.Properties as Properties
import javax.management.ObjectName as ObjectName
import com.ibm.websphere.management.AdminClient as AdminClient
import com.ibm.websphere.management.AdminClientFactory as AdminClientFactory
class DeploymentManager:
def __init__(self, host, soapport, user, password):
self.host = host
self.soapport = soapport
self.user = user
self.password = password
def create_admin_client(dmgrhost, dmgrsoapport, user, password):
props = Properties()
props.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP)
props.setProperty(AdminClient.CONNECTOR_HOST, dmgrhost)
props.setProperty(AdminClient.CONNECTOR_PORT, dmgrsoapport)
props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
props.setProperty(AdminClient.USERNAME, user);
props.setProperty(AdminClient.PASSWORD, password);
props.setProperty("javax.net.ssl.trustStore",
"/opt/IBM/Profiles/dmgr01/etc/DummyClientTrustFile.jks");
props.setProperty("javax.net.ssl.keyStore",
"/opt/IBM/Profiles/dmgr01/etc/DummyClientKeyFile.jks");
adminClient = AdminClientFactory.createAdminClient(props)
return adminClient
def get_servers():
servers = [s for s in adminClient.queryNames(queryName, None).toArray()]
return servers
def get_server_states(servers):
serverstates = {}
for server in servers:
name = adminClient.getAttribute(server, "name")
pid = adminClient.getAttribute(server, "pid")
state = adminClient.getAttribute(server, "state")
serverstates[name] = {'name' : name, 'state' : state, 'pid' : pid}
return serverstates
DMGRs = []
DMGRs.append(DeploymentManager('dmgr1_host', 'dmgr1_soap_port', 'dmgr1_user', 'dmgr1_pw'))
DMGRs.append(DeploymentManager('dmgr2_host', 'dmgr2_soap_port', 'dmgr2_user', 'dmgr2_pw'))
DMGRs.append(DeploymentManager('dmgr3_host', 'dmgr3_soap_port', 'dmgr3_user', 'dmgr3_pw'))
for DMGR in DMGRs:
adminClient = create_admin_client(DMGR.host, DMGR.soapport, DMGR.user, DMGR.password)
queryName = ObjectName("WebSphere:*,node=*,type=Server,name=srv*")
servers = get_servers()
serverstates = get_server_states(servers)
print '## %s ##' % DMGR.host
keys = serverstates.keys()
keys.sort()
for key in keys:
print '%s %s: %s' % (serverstates[key]['name'],
serverstates[key]['pid'],
serverstates[key]['state'])
print
Here's the error I see when I run it:
jython -Dpython.path=/opt/IBM/WebSphere/AppServer/runtimes/com.ibm.ws.admin.client_7.0.0.jar:/opt/IBM/WebSphere/AppServer/plugins/com.ibm.ws.security.crypto.jar:/opt/IBM/WebSphere/AppServer/plugins/com.ibm.ws.runtime.jar -Dcom.ibm.SOAP.ConfigURL=/opt/IBM/Profiles/dmgr01/properties/soap.client.props was_common.py
Apr 16, 2012 3:07:39 PM com.ibm.ws.management.connector.interop.JMXClassLoader
WARNING: Could not find tmx4jTransform.jar in null/etc/tmx4jTransform.jar - Interoperability to older versions of WebSphere is disabled
Apr 16, 2012 3:07:40 PM com.ibm.ws.ssl.config.SSLConfigManager
INFO: ssl.disable.url.hostname.verification.CWPKI0027I
Apr 16, 2012 3:07:40 PM com.ibm.ws.security.config.SecurityObjectLocator
INFO: Client code attempting to load security configuration
Traceback (most recent call last):
File "was_common.py", line 56, in <module>
adminClient = create_admin_client(DMGR.host, DMGR.soapport, DMGR.user, DMGR.password)
File "was_common.py", line 30, in create_admin_client
adminClient = AdminClientFactory.createAdminClient(props)
at com.ibm.websphere.management.AdminClientFactory.createAdminClientPrivileged(AdminClientFactory.java:632)
at com.ibm.websphere.management.AdminClientFactory.access$000(AdminClientFactory.java:123)
at com.ibm.websphere.management.AdminClientFactory$1.run(AdminClientFactory.java:206)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
at com.ibm.websphere.management.AdminClientFactory.createAdminClient(AdminClientFactory.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
com.ibm.websphere.management.exception.ConnectorException: com.ibm.websphere.management.exception.ConnectorException: ADMC0016E: The system cannot create a SOAP connector to connect to host dmgr1_host at port dmgr1_soap_port
Note: I changed some values in this example to generic values.