ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

java.lang.SecurityException:期望存根中的sun.rmi.server.UnicastRef2远程引用

2019-06-28 13:49:18  阅读:270  来源: 互联网

标签:ubuntu java jmx jconsole


我正在尝试使用我的Ubuntu机器上的JConsole工具连接到在不同机器上运行的远程Java进程.

这就是我在远程机器上运行Java程序的方法:

sudo java -Dcom.sun.management.jmxremote.port=51082
-Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar myfile.jar

我正在我的机器上运行JConsole命令,如下所示:

jconsole -debug -J-Djava.util.logging.config.file=Logging.properties

这是我的Logging.properties文件:

handlers = java.util.logging.ConsoleHandler

sun.rmi.level=FINEST
.level = INFO

java.util.logging.ConsoleHandler.level = FINEST

java.util.logging.ConsoleHandler.formatter = \

java.util.logging.SimpleFormatter

// Use FINER or FINEST for javax.management.remote.level - FINEST is

// very verbose...

javax.management.level = FINEST

javax.management.remote.level = FINER

现在在我的Jconsle UI上,我给出了以下属性:

当我点击Connect按钮时,我得到例外说:

    FINER: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://my-remote-host:51082/jmxrmi] failed to connect: java.lang.SecurityException: Expecting a sun.rmi.server.UnicastRef2 remote reference in stub!
    java.lang.SecurityException: Expecting a sun.rmi.server.UnicastRef2 remote reference in stub!

This is the complete stacktrace of the exception as per logs:

Jul 14, 2015 7:39:55 PM RMIConnector connect
FINER: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://my-remote-host:51082/jmxrmi] connecting...
Jul 14, 2015 7:39:55 PM RMIConnector connect
FINER: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://my-remote-host:51082/jmxrmi] finding stub...
Jul 14, 2015 7:39:55 PM sun.rmi.transport.tcp.TCPEndpoint <clinit>
FINE: VMPanel.connect: localHostKnown = true, localHost = 127.0.0.8
Jul 14, 2015 7:39:55 PM sun.rmi.server.UnicastRef newCall
FINE: VMPanel.connect: get connection
Jul 14, 2015 7:39:55 PM sun.rmi.transport.tcp.TCPTransport <init>
FINE: VMPanel.connect: Version = 2, ep = [127.0.0.8:0]
Jul 14, 2015 7:39:55 PM sun.rmi.transport.tcp.TCPEndpoint getLocalEndpoint
FINE: VMPanel.connect: created local endpoint for socket factory null on port 0
Jul 14, 2015 7:39:55 PM sun.rmi.transport.tcp.TCPChannel createConnection
FINE: VMPanel.connect: create connection
Jul 14, 2015 7:39:55 PM sun.rmi.transport.tcp.TCPEndpoint newSocket
FINER: VMPanel.connect: opening socket to [my-remote-host:51082]
Jul 14, 2015 7:39:55 PM sun.rmi.transport.proxy.RMIMasterSocketFactory createSocket
FINE: VMPanel.connect: host: my-remote-host, port: 51082
Jul 14, 2015 7:39:58 PM sun.rmi.transport.tcp.TCPChannel createConnection
FINER: VMPanel.connect: server suggested 10.56.36.2:36585
Jul 14, 2015 7:39:58 PM sun.rmi.transport.tcp.TCPChannel createConnection
FINER: VMPanel.connect: using 127.0.0.8:0
Jul 14, 2015 7:39:58 PM sun.rmi.server.UnicastRef newCall
FINER: VMPanel.connect: create call context
Jul 14, 2015 7:39:58 PM sun.rmi.server.UnicastRef logClientCall
FINER: VMPanel.connect: outbound call: [endpoint:[my-remote-host:51082](remote),objID:[0:0:0, 0]] : sun.rmi.registry.RegistryImpl_Stub[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)
Jul 14, 2015 7:39:58 PM sun.rmi.transport.StreamRemoteCall <init>
FINER: VMPanel.connect: write remote call header...
Jul 14, 2015 7:39:58 PM sun.rmi.transport.StreamRemoteCall getOutputStream
FINER: VMPanel.connect: getting output stream
Jul 14, 2015 7:39:58 PM sun.rmi.server.UnicastRef invoke
FINER: VMPanel.connect: execute call
Jul 14, 2015 7:39:59 PM sun.rmi.transport.StreamRemoteCall getInputStream
FINER: VMPanel.connect: getting input stream
Jul 14, 2015 7:39:59 PM sun.rmi.server.LoaderHandler loadClass
FINE: VMPanel.connect: name = "javax.management.remote.rmi.RMIServerImpl_Stub", codebase = "", defaultLoader = sun.misc.Launcher$AppClassLoader@530f243b
Jul 14, 2015 7:39:59 PM sun.rmi.server.LoaderHandler loadClass
FINER: VMPanel.connect: class "javax.management.remote.rmi.RMIServerImpl_Stub" found via defaultLoader, defined by null
Jul 14, 2015 7:39:59 PM sun.rmi.server.LoaderHandler loadClass
FINE: VMPanel.connect: name = "java.rmi.server.RemoteStub", codebase = "", defaultLoader = sun.misc.Launcher$AppClassLoader@530f243b
Jul 14, 2015 7:39:59 PM sun.rmi.server.LoaderHandler loadClass
FINER: VMPanel.connect: class "java.rmi.server.RemoteStub" found via defaultLoader, defined by null
Jul 14, 2015 7:39:59 PM sun.rmi.server.LoaderHandler loadClass
FINE: VMPanel.connect: name = "java.rmi.server.RemoteObject", codebase = "", defaultLoader = sun.misc.Launcher$AppClassLoader@530f243b
Jul 14, 2015 7:39:59 PM sun.rmi.server.LoaderHandler loadClass
FINER: VMPanel.connect: class "java.rmi.server.RemoteObject" found via defaultLoader, defined by null
Jul 14, 2015 7:39:59 PM sun.rmi.server.UnicastRef done
FINE: VMPanel.connect: free connection (reuse = true)
Jul 14, 2015 7:39:59 PM sun.rmi.transport.tcp.TCPChannel free
FINE: VMPanel.connect: reuse connection
Jul 14, 2015 7:39:59 PM sun.rmi.transport.tcp.TCPChannel free
FINE: VMPanel.connect: create reaper
Jul 14, 2015 7:39:59 PM sun.rmi.server.UnicastRef newCall
FINE: VMPanel.connect: get connection
Jul 14, 2015 7:39:59 PM sun.rmi.transport.tcp.TCPChannel createConnection
FINE: VMPanel.connect: create connection
Jul 14, 2015 7:39:59 PM sun.rmi.transport.tcp.TCPEndpoint newSocket
FINER: VMPanel.connect: opening socket to [127.0.1.1:57675]
Jul 14, 2015 7:39:59 PM sun.rmi.transport.proxy.RMIMasterSocketFactory createSocket
FINE: VMPanel.connect: host: 127.0.1.1, port: 57675
Jul 14, 2015 7:39:59 PM sun.rmi.server.UnicastRef newCall
FINE: RMI RenewClean-[127.0.1.1:57675]: get connection
Jul 14, 2015 7:39:59 PM sun.rmi.transport.tcp.TCPChannel createConnection
FINE: RMI RenewClean-[127.0.1.1:57675]: create connection
Jul 14, 2015 7:39:59 PM sun.rmi.transport.tcp.TCPEndpoint newSocket
FINER: RMI RenewClean-[127.0.1.1:57675]: opening socket to [127.0.1.1:57675]
Jul 14, 2015 7:39:59 PM sun.rmi.transport.WeakRef pin
FINER: VMPanel.connect: strongRef = sun.rmi.transport.DGCImpl@63a1b509
Jul 14, 2015 7:40:00 PM sun.rmi.transport.proxy.RMIMasterSocketFactory createSocket
FINE: RMI RenewClean-[127.0.1.1:57675]: host: 127.0.1.1, port: 57675
Jul 14, 2015 7:40:00 PM sun.rmi.transport.ObjectTable putTarget
FINER: VMPanel.connect: add object [0:0:0, 2]
Jul 14, 2015 7:40:00 PM sun.rmi.transport.ConnectionInputStream done
FINER: VMPanel.connect: send ack
Jul 14, 2015 7:40:00 PM sun.rmi.transport.tcp.TCPChannel newConnection
FINE: VMPanel.connect: reuse connection
Jul 14, 2015 7:40:00 PM sun.rmi.transport.tcp.TCPChannel free
FINE: VMPanel.connect: reuse connection
Jul 14, 2015 7:40:00 PM RMIConnector connect
FINER: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://my-remote-host:51082/jmxrmi] failed to connect: java.lang.SecurityException: Expecting a sun.rmi.server.UnicastRef2 remote reference in stub!
java.lang.SecurityException: Expecting a sun.rmi.server.UnicastRef2 remote reference in stub!
    at javax.management.remote.rmi.RMIConnector.checkStub(RMIConnector.java:1871)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:295)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)
    at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:357)
    at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:313)
    at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:292)
Jul 14, 2015 7:40:01 PM sun.rmi.server.UnicastRef newCall
FINE: RMI RenewClean-[127.0.1.1:57675]: get connection
Jul 14, 2015 7:40:01 PM sun.rmi.transport.tcp.TCPChannel createConnection

我无法弄清问题在哪里.

更新:

我可以连接到我的远程主机以获取给定端口:

telnet my_remote_host 51082

根据this link,我得到了主机的回复,没有任何问题.

解决方法:

请使用以下设置.我也遇到了同样的问题,但在设置不足后解决了

-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.port=9704 
-Djava.rmi.server.hostname=172.18.137.35 
-Dcom.sun.management.jmxremote.rmi.port=970

请注意Djava.rmi.server.hostname和Dcom.sun.management.jmxremote.rmi.port.

即使在这个设置之后它会要求不安全的连接请接受它然后你就能连接(它会给你错误和连接失败:java.lang.SecurityException:期望sun.rmi.server.UnicastRef2远程引用存根!).

标签:ubuntu,java,jmx,jconsole
来源: https://codeday.me/bug/20190628/1316096.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有