Linux 上的 java.rmi.NoSuchObjectException [英] java.rmi.NoSuchObjectException on Linux

查看:39
本文介绍了Linux 上的 java.rmi.NoSuchObjectException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在通过 RMI 连接的应用程序开发两个.通信是双向的,一切正常,直到我在 Windows 上运行.当我将 jar 文件带到 Debian 时,连接失败并显示 java.rmi.NoSuchObjectException.

知道 linux 有什么不同,或者为什么它不起作用?



i'm developing two via RMI connected apps. Communication is bidirectional and everything works just fine, until i'm running on windows. when i take jar files to Debian, connection fails with java.rmi.NoSuchObjectException.

Any idea what difference linux makes or why isn't it working ?

我的代码:
服务器端:

my code:
Server side:

static Registrator clientRegistrator = null; // static field, interface extending java.rmi.Remote
...
Registry rmiRegistry = LocateRegistry.createRegistry(RmiConstants.RMI_REGISTRY_PORT);
clientRegistrator = (Registrator) UnicastRemoteObject.exportObject(new RmiClientRegistrator(networkListeners), RmiConstants.RMI_REGISTRY_PORT); // RmiClientRegistrator implements Registrator interface
rmiRegistry.bind(RmiConstants.RMI_SERVER_MARK, clientRegistrator);


客户端:


Client side:

static Registrator serverRegistrator = null;
String rmiConnectionString = "rmi://localhost:" + RmiConstants.RMI_REGISTRY_PORT + "/" + RmiConstants.RMI_SERVER_MARK;
serverRegistrator = (Registrator) Naming.lookup(rmiConnectionString);
serverRegistrator.registerClient(dataReceiver); // fails here, with mentioned exception

推荐答案

您的存根引用的远程对象不再存在.更准确地说,它不再导出.除非您自己取消导出它,或者除非网络分区导致 DGC 失败,否则在客户端仍有实时存根时不应发生这种情况.

The remote object referred to by your stub no longer exists. More accurately, it is no longer exported. This shouldn't happen while a client still has a live stub to it, unless you unexported it yourself, or unless a network partition caused a DGC failure.

最可靠的补救措施是在 JVM 中保留对远程对象的静态引用.

The surest remedy against this is to keep a static reference to the remote object in the JVM it was exported from.

这篇关于Linux 上的 java.rmi.NoSuchObjectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆