AdminClient ac = null;
Properties props = new Properties();
props.setProperty(AdminClient.CONNECTOR_TYPE,AdminClient.CONNECTOR_TYPE_SOAP);
props.setProperty(AdminClient.CONNECTOR_HOST, "localhost");
props.setProperty(AdminClient.CONNECTOR_PORT, "8879");
props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
props.setProperty(AdminClient.CONNECTOR_AUTO_ACCEPT_SIGNER, "ture");
props.setProperty(AdminClient.USERNAME, "admin");
props.setProperty(AdminClient.PASSWORD, "liqing");
props.setProperty("javax.net.ssl.trustStore", "E:/IBM/WebSphere/AppServer/profiles/Dmgr01/config/cells/USER-20150121SFCell01/trust.p12");
props.setProperty("javax.net.ssl.keyStore", "E:/IBM/WebSphere/AppServer/profiles/Dmgr01/config/cells/USER-20150121SFCell01/key.p12");
props.setProperty("javax.net.ssl.trustStorePassword", "12345");
props.setProperty("javax.net.ssl.keyStorePassword", "12345");
ac = AdminClientFactory.createAdminClient(props);
String domainName = ac.getDomainName();
System.out.println(domainName);
错误:4月 02, 2015 10:02:58 上午 com.ibm.ws.security.config.SecurityObjectLocator
INFO: Client code attempting to load security configuration
4月 02, 2015 10:02:58 上午 com.ibm.ws.ssl.config.KeyStoreManager
WARNING: ssl.keystore.type.invalid.CWPKI0018W
4月 02, 2015 10:02:59 上午 com.ibm.ws.ssl.config.KeyStoreManager
WARNING: ssl.keystore.type.invalid.CWPKI0018W
Exception in thread "main" com.ibm.websphere.management.exception.ConnectorException: ADMC0016E: 系统无法创建 SOAP 连接器以连接到端口 8879 上的主机 localhost。
at com.ibm.websphere.management.AdminClientFactory.createAdminClientPrivileged(AdminClientFactory.java:635)
at com.ibm.websphere.management.AdminClientFactory.access$000(AdminClientFactory.java:127)
at com.ibm.websphere.management.AdminClientFactory$1.run(AdminClientFactory.java:210)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
at com.ibm.websphere.management.AdminClientFactory.createAdminClient(AdminClientFactory.java:206)
at test.WebsphereTest.start(WebsphereTest.java:26)
at test.Test.main(Test.java:10)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at com.ibm.websphere.management.AdminClientFactory.createAdminClientPrivileged(AdminClientFactory.java:457)
... 6 more
Caused by: com.ibm.websphere.management.exception.ConnectorNotAvailableException: [SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket: java.io.IOException: Exception during sslSocket.startHandshake: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty; targetException=java.lang.IllegalArgumentException: Error opening socket: java.io.IOException: Exception during sslSocket.startHandshake: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty]
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SOAPConnectorClient.java:422)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.
(SOAPConnectorClient.java:222)
... 11 more
Caused by: [SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket: java.io.IOException: Exception during sslSocket.startHandshake: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty; targetException=java.lang.IllegalArgumentException: Error opening socket: java.io.IOException: Exception during sslSocket.startHandshake: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty]
at org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.java:475)
at org.apache.soap.rpc.Call.WASinvoke(Call.java:464)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient$4.run(SOAPConnectorClient.java:380)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SOAPConnectorClient.java:365)
... 12 more
这是读取不到密钥还是信任库库证书嘛收起