NoSuchObjectException exception in RMI

本文探讨了使用RMI调用时遇到java.rmi.NoSuchObjectException异常的问题,该问题可能由网络故障导致。文章提供了详细的解决方案,包括通过创建RMIHelper和服务保持器类来避免远程对象被垃圾回收。

If you are using RMI calling, this exception java.rmi.NoSuchObjectException maybe come up after network failed.

Perhaps the root causation is an issue(or bug) of RMI: the binded implement object has been GCed by DGC protocol.

we can reference this URL for detail:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4114579

 

To reproduce this failure, we can break down the network connection on a Server for a while, then restore network and execute :

interface = Naming.lookup();

interface.methodName();  // NoSuchObjectException will throw out

 

To resolve this problem, you can add two classes RMIHelper, ServiceObjectKeeper to encapsulate RMI calling, and replace all old calling

Naming.rebind() with RMIHelper.rebind(), Naming.bind() with RMIHelper.bind().

Thus will hold a strong reference to the remote object in the local VM.

 

The following content is picked up from J2SDK, it point out Java have a hidden trouble on this topic.

Note that if a network partition exists between a client and a remote server object, it is possible that premature collection of the remote object will occur (since the transport might believe that the client crashed). Because of the possibility of premature collection, remote references cannot guarantee referential integrity; in other words, it is always possible that a remote reference may in fact not refer to an existing object. An attempt to use such a reference will generate a RemoteException which must be handled by the application.

--- From J2SDK 1.4.1

  Java Remote Method Invocation – 3.3 Garbage Collection of Remote Objects

 

 

按照你说的改了,还是有问题[root@rockylinux001 bin]# ./jmeter-server -Djava.rmi.server.hostname=192.168.64.137 -Dserver_port=1099 WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release Using local port: 1099 Created remote object: UnicastServerRef2 [liveRef: [endpoint:[192.168.64.137:1099,SSLRMIServerSocketFactory(host=/192.168.64.137, keyStoreLocation=rmi_keystore.jks, type=JKS, trustStoreLocation=rmi_keystore.jks, type=JKS, alias=rmi),SSLRMIClientSocketFactory(keyStoreLocation=rmi_keystore.jks, type=JKS, trustStoreLocation=rmi_keystore.jks, type=JKS, alias=rmi)](local),objID:[-7670ffa6:197cf478f7f:-7fff, -5523187121662620433]]] Problem creating registry: java.rmi.server.ExportException: Listen failed on port: 1099; nested exception is: java.io.IOException: Could not bind to /192.168.64.137 using port 1099 Continuing... Server failed to start: java.rmi.RemoteException: Cannot start. See server log file.; nested exception is: java.rmi.NoSuchObjectException: no such object in table An error occurred: Cannot start. See server log file.; nested exception is: java.rmi.NoSuchObjectException: no such object in table
07-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值