java.io.IOException:Failed to retrieve RMIServer stub:javax.naming.ServiceUnavailableExcetpion
Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:求大神解决
环境Linux,JBoss7
Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:求大神解决
环境Linux,JBoss7
解析为IP 127.0.0.1,当客户端向服务器Lookup时,服务端就会把解析出来的地址发给客户端,让客户端再根据这个地址去
连接,客户端收到127.0.0.1这个地址去连接,实际连接的是自己本身,当然也就不行了。 更正办法:把Naming.rebind("SectionWorkerManager", manager);
改成Naming.rebind("rmi://10.1.5.xxx:1099/SectionWorkerManager", manager);,直接用IP地址(10.1.5.xxx:1099为服务器本身IP),这样就没问题了;
或者是用机器名,该服务器的名字为RHELTEST,把它加到服务器的hosts文件中,并放在127.0.0.1之前,以让该服务能正确解析出来机器
名所对应的IP;要么用域名解析也行,这种方法比较适合大规模场合。 在Windows下能正常工作,在linux下却不行,这可能是操作系统解析localhost为ip时时的机制不一样引起的。
jboss-as-7.1.1.Final\standalone\configuration\standalone.xml 找到
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
把 value="${jboss.bind.address:127.0.0.1} 改成 value="${0.0.0.0} 或者是 value="${jboss.bind.address:xxxx} 你的IP