【发布时间】:2012-09-11 06:06:12
【问题描述】:
我第一次尝试使用 RMI 注册表进行远程调用。我已经编写了实现它的接口和类。当我试图调用它时,我面临着这个问题。我通过提供start rmiregistry 在我的 Windows 机器上启动了 rmiregistry,这会打开一个新窗口。
客户端prg看起来像:
String host = "172.27.49.199:1099";
try {
System.out.println(LocateRegistry.getRegistry());
Registry registry = LocateRegistry.getRegistry(host,0);
Details stub = (Details) registry.lookup("Hello");
String response = stub.Name();
System.out.println("response: " + response);
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
我对需要为host 赋予什么值感到困惑。
我尝试过给予:
(a)http://localhost
(b)http://localhost:1099
它离开java.net.UnknownHostException: http://localhost:1099。
更新:
将主机更改为My_Sys_IP后,我丢失了java.net.UnknownHostException,但最终得到了Client exception: java.rmi.NotBoundException: Details
【问题讨论】:
-
NotBoundException表示您查找的项目不存在。我怀疑您正在与错误的注册表交谈:请参阅我的答案下方的 cmets。
标签: java rmi rmiregistry