2013-03-27 85 views
1

我試圖創建的WebSphere簡單的管理客戶端應用程序:WebSphere管理工具應用

我的代碼:

Properties connectProps = new Properties(); connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP); connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");

connectProps.setProperty(AdminClient.CONNECTOR_HOST, "XXXXX"); connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8879"); connectProps.setProperty(AdminClient.USERNAME, "admin"); connectProps.setProperty(AdminClient.PASSWORD, "admin"); connectProps.setProperty("javax.net.ssl.trustStore","C:\Users\DummyClientTrustFile.jks"); connectProps.setProperty("javax.net.ssl.keyStore", "C:\Users\DummyClientKeyFile.jks"); connectProps.setProperty("javax.net.ssl.trustStorePassword", "admin"); connectProps.setProperty("javax.net.ssl.keyStorePassword", "admin");

AdminClient adminClient = null; try { adminClient = AdminClientFactory.createAdminClient(connectProps); } catch (ConnectorException e) { System.out.println("Exception creating admin client: " + e);

e.printStackTrace(); } 

}

錯誤消息我收到:

com.ibm.websphere.management.exception.ConnectorException: ADMC0016E:The system cannot create a SOAP connector to connect to host xxxx at port 8879. at com.ibm.websphere.management.AdminClientFactory.createAdminClientPriv ileged(AdminClientFactory.java:635) at com.ibm.websphere.management.AdminClientFactory.access$000(AdminClien tFactory.java:127) at com.ibm.websphere.management.AdminClientFactory$1.run(AdminClientFact ory.java:210) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll er.java:63) at com.ibm.websphere.management.AdminClientFactory.createAdminClient(Adm inClientFactory.java:206) at TryConnection1.main(TryConnection1.java:42) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou 

rce) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.ibm.websphere.management.AdminClientFactory.createAdminClientPriv ileged(AdminClientFactory.java:457) ... 5 more Caused by: java.lang.NoSuchMethodError: org.apache.soap.rpc.Call.WASinvoke(Ljava /net/URL;Ljava/lang/String;)Lorg/apache/soap/rpc/Response; at com.ibm.ws.management.connector.soap.SOAPConnectorClient$4.run(SOAPCo nnectorClient.java:373) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll er.java:118) at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SO APConnectorClient.java:366) at com.ibm.ws.management.connector.soap.SOAPConnectorClient.(SOAPC onnectorClient.java:222) ... 10 more ---- Begin backtrace for nested exception java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou 

rce) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.ibm.websphere.management.AdminClientFactory.createAdminClientPriv ileged(AdminClientFactory.java:457) at com.ibm.websphere.management.AdminClientFactory.access$000(AdminClien tFactory.java:127) at com.ibm.websphere.management.AdminClientFactory$1.run(AdminClientFact ory.java:210) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll er.java:63) at com.ibm.websphere.management.AdminClientFactory.createAdminClient(Adm inClientFactory.java:206) at TryConnection1.main(TryConnection1.java:42) Caused by: java.lang.NoSuchMethodError: org.apache.soap.rpc.Call.WASinvoke(Ljava /net/URL;Ljava/lang/String;)Lorg/apache/soap/rpc/Response; at com.ibm.ws.management.connector.soap.SOAPConnectorClient$4.run(SOAPCo nnectorClient.java:373) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll er.java:118) at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SO APConnectorClient.java:366) at com.ibm.ws.management.connector.soap.SOAPConnectorClient.(SOAPC onnectorClient.java:222) ... 10 more

回答

0

好像你在你的classpath中混合了錯誤的jar/jre。可能是IBM的adminclient jar和sun JRE?或錯誤的XML /肥皂罐?

我從來沒有真正嘗試直接調用adminclient罐子。更好的支持方式是使用IBM的wsadmin.sh腳本並通過jython調用AdminClient接口。在屏幕背後,這也將做你從java做的事情,所以你可以反向設計這個腳本來看看哪個jre和哪個jar被實際用來做出神奇的工作。對於wsadmin的websphere v6.1文檔,請參閱http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/rxml_commandline.html