我是JMX的新手。我需要创建一个自定义JMX客户端,它将连接到远程服务器并从mbeans读取数据。
这是我到目前为止的应用代码:
String url = "service:jmx:rmi:///jndi/rmi://host:port/jmxrmi";
JMXServiceURL serviceURL = new JMXServiceURL(url);
Map env = new HashMap();
String[] creds = { "role", "password" };
env.put(JMXConnector.CREDENTIALS, creds);
JMXConnector cc = JMXConnectorFactory.connect(serviceURL, env);
MBeanServerConnection mbsc = cc.getMBeanServerConnection();
当我启动我的应用程序时,我收到以下错误(已修改为添加完整堆栈跟踪):
Exception in thread "main" java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:304)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:308)
at Main.main(Main.java:21)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2430)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.DataOutputStream.flush(DataOutputStream.java:123)
... 9 more
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:229)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
... 20 more
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
... 26 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
任何帮助都将不胜感激。
答案 0 :(得分:1)
问题在于客户端密钥库中缺少服务器证书。