2017年9月6日 | Leave a comment 问题: RMI InitialContext.bind throw javax.naming.ServiceUnavailableException Exception in thread "main" javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.198.105; nested exception is: java.net.ConnectException: Connection refused] at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:147) at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:228) at javax.naming.InitialContext.bind(InitialContext.java:425) at rmi1.server.App.main(App.java:23) 123456 Exception in thread "main" javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.198.105; nested exception is: java.net.ConnectException: Connection refused] at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:147) at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:228) at javax.naming.InitialContext.bind(InitialContext.java:425) at rmi1.server.App.main(App.java:23) 解决: 在server服务器执行 rmiregistry 启动 rmi 注册中心 参考: http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html