gpt4 book ai didi

java - 调用 "lookup"后,本地网络上的 RMI 出现 NotBoundException-Exception

转载 作者:行者123 更新时间:2023-12-02 07:23:56 25 4
gpt4 key购买 nike

我在 RMI 上遇到问题:

我的RMI客户端尝试获取192.168.1.37的注册表

Registry registry = LocateRegistry.getRegistry("192.168.1.37",1099);
String[] s = registry.list();
for( String obj : s ) {
System.out.println(" " + obj);
}
IMaster master = (IMaster) registry.lookup ("rmi://192.168.1.37:1099/Master");

我的 RMI 服务器如下所示:

Registry registry = LocateRegistry.getRegistry();
IMaster m = new Master(3, 3);
registry.rebind ("Master", m);
System.out.println ("Master Server is ready.");

registry-List [String[] s =registry.list();] 知道“Master”绑定(bind)。这意味着:网络没有问题并且注册表存在。该对象也已导出。 (我使用 RMI 的 eclipse 插件)。

但是在客户端的查找行中我遇到了异常:

java.rmi.NotBoundException: rmi://192.168.1.37:1099/Master
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:136)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at philosoper.client.ClientServer.main(ClientServer.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at net.genady.rmi.logger.Runner.main(Runner.java:137)

有人知道如何解决这个问题吗? :)谢谢

最佳答案

尝试改变

IMaster master = (IMaster) registry.lookup ("rmi://192.168.1.37:1099/Master");

IMaster master = (IMaster) registry.lookup ("Master");

关于java - 调用 "lookup"后,本地网络上的 RMI 出现 NotBoundException-Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13791823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com