首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

RMI 调用错误

2013-08-26 
RMI 调用异常java.rmi.ConnectException: Connection refused to host: 127.0.0.1 nested exception is:j

RMI 调用异常

java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:    java.net.ConnectException: Connection refused

?

最近在做ehcache的分布式(RMI)缓存的时候发现这个异常,折腾了好一会儿

?

看官方解释:

写道Essentially, this java call: InetAddress.getLocalHost();always returns the loopback address, which is 127.0.0.1. Why? Because in these recent distros, a system call of $ hostname always returns an address mapped onto the loopback device. Which causes ehcache’s RMI Peer creation logic to always assign the loopback address, which causes the error you are seeing.
All you need to do is crack open the network con?g and make sure that the hostname of the machine returns a valid network address accessible by other peers on the network.

?

大概意思是hostname对应的ip地址是要能被远程调用者能访问,一般情况下在hosts里面加上

写道hostName IP#能被远程调用的IP,比如调用者在局域网,则应该是本机的局域网IP

?

其实不难理解

?

如果你返回的rmi对象包含的是127.0.0.1,调用者根据这个地址调用时会调用到本机....而本机没有这个rmi服务,所以出现上述异常.

?

热点排行