使用JMX接口来编写PMI应用程序进行实时监控
我想使用JMX接口来编写PMI应用程序进行实时监控,参照网上资料编写了一个程序,但运行时总是报“系统无法创建 SOAP 连接器以连接到端口 8880 上的主机 localhost”,我的主机名端口都没问题,网上查找了一些资料,有说是要去掉登录名和密码,有说是要设置ssl的,这些我都试了,运行时还是报相同的错,我觉得可能是由于环境的问题,请问该如何解决?代码:
Properties connectProps = new Properties();
connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
connectProps.setProperty(AdminClient.CONNECTOR_HOST, "localhost");
connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8880");
connectProps.setProperty(AdminClient.CONNECTOR_SOAP_CONFIG, "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/properties/soap.
client.props");
connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
connectProps.setProperty(AdminClient.USERNAME, "user");
connectProps.setProperty(AdminClient.PASSWORD, "pwd");
connectProps.setProperty("javax.net.ssl.trustStore", "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/etc/DummyClientTrustFil
e.jks");
connectProps.setProperty("javax.net.ssl.keyStore", "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/etc/DummyClientTrustFile.
jks");
connectProps.setProperty("javax.net.ssl.trustStorePassword", "WebAS");
connectProps.setProperty("javax.net.ssl.keyStorePassword", "WebAS");
try
{
adminClient = AdminClientFactory.createAdminClient(connectProps);
}
catch (ConnectorException e)
{
System.out.println("Exception creating admin client: " + e);
System.exit(-1);
}
编译运行:
source /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/setupCmdLine.sh
$JAVA_HOME/bin/javac -cp .:$WAS_CLASSPATH:$JAVA_HOME/lib/dt.jar:$WAS_HOME/runtimes/com.ibm.ws.admin.client_7.0.0.jar:$WAS_HOME/runtimes/com.ibm.jaxws.thinclient_7.0.0.jar:$WAS_HOME/lib/webadmin/management.jar:$WAS_HOME/plugins/com.ibm.ws.security.crypto.jar AdminClientExample.java
$JAVA_HOME/bin/java -cp .:$WAS_CLASSPATH:$JAVA_HOME/lib/dt.jar:$WAS_HOME/runtimes/com.ibm.ws.admin.client_7.0.0.jar:$WAS_HOME/runtimes/com.ibm.jaxws.thinclient_7.0.0.jar:$WAS_HOME/lib/webadmin/management.jar:$WAS_HOME/plugins/com.ibm.ws.security.crypto.jar -Dwas.install.root=${WAS_HOME} -Dwas.repository.root=${CONFIG_ROOT} -Djava.ext.dirs=${WAS_EXT_DIRS} AdminClientExample --------------------编程问答-------------------- SSL连接只需设置javax.net.ssl.trustStore和javax.net.ssl.trustStorePassword --------------------编程问答-------------------- 谢谢,但还是无法创建 SOAP 连接
补充:企业软件 , WebSphere