调用远程主机上的 RMI 服务时抛出 java.rmi.ConnectException: C
|
最近使用 jmx 遇到一个问题,client/server 同在一台机器上,jmx client能够成功连接 server,如果把 server 移植到另一台机器上192.168.134.128,抛出如下异常: java.net.ConnectException: Connection refused: connect
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.getAllSections(Unknown Source)
at ccg.boccrawler.rmi.TestClient.main(TestClient.java:21)
原因:这个问题其实是由 rmi 服务器端程序造成的。 客户端程序向服务端请求一个对象的时候,返回的 stub 对象里面包含了服务器的 hostname,客户端的后续操作根据这个 hostname 来连接服务器端。要想知道这个hostname 具体是什么值可以在服务器端 bash 中打入指令: 解决方法有两种:
如你的 hosts 文件原来内容
机器的实际 IP 为192.168.134.132,则可以添加以下内容
然后修改 /etc/sysconfig/network 文件的 HOSTNAME=test,则可以访问成功。
(编辑:拼字网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 乐视x55 pro与小米电视3 60寸的区别 小米电视3和乐视x55 pr
- linux – 期望脚本期望错过发送字符串延迟问题
- IP Failover Setup using Keepalived on CentOS/Redhat 6
- awk - Unix, Linux Command---reference
- AMD 开发了一个有助于提升 Linux 性能的 PAN 功能
- Linux 内存监控内存泄露和回收内存的方法
- linux – gcc 4.x不支持x87 FPU数学?
- 疯狂猜歌乐队答案大全
- 放绝招!Docker Desktop 宣布支持 Linux
- 20+ Rsync command’s switches and common usages with ex

