Xiaohua Yang 2019-05-30 10:33 采纳率: 0%
浏览 849

RMI调用的java.rmi.NoSuchObjectException: no such object exception

Server Runner:

public interface Triggerable extends Remote {…}

Runner obj = new Runner();
stub = (Triggerable) UnicastRemoteObject.exportObject(obj, 0);
registry = LocateRegistry.getRegistry(host,port);
registry.bind("Hello", stub);

Client:

Registry runnerRegistry;
private Triggerable runner;
runnerRegistry = LocateRegistry.getRegistry(ServerConfig.getRunnerIP(),ServerConfig.getRunnerPort());
runner = (Triggerable) runnerRegistry.lookup("Hello");

Server和client2个进程启动后connect 成功。

程序流程:
1. Client:
public interface Notifier extends Remote{......}
public class RunnerListener implements Notifier{
public void notify(String content) throws RemoteException {
.....do some actions here…….
UnicastRemoteObject.unexportObject(this, true);
}
…….
}

        RunnerListener nf = new RunnerListener(this);
        Notifier rnf = (Notifier) UnicastRemoteObject.exportObject(nf, 0);
        String content ="Test";
        runner.create(content, rnf);

2. Server:调用client 的notify();
        …
        rnf.notify(content);

问题:client 会根据需要多次生成Notifier 并且调用 Server function with Notifier object. Server 做完相应的操作后,会回调 client 的 函数
rnf.notify(content)。 刚开始1,2天工作正常,但往后时不时的就会出现调用异常。

java.rmi.NoSuchObjectException: no such object in table

at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:283)

at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:260)

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)

at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)

at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)

at com.sun.proxy.$Proxy1.notify(Unknown Source)

问题是:server端调用client 的notify(), 有的对象可以调用成功,有的对象调用失败。如果说registry 对象被回收,后续的所有调用都应该失败。那就有可能是client export的notifier对象被回收,那该如何处理?

另外,这段代码在java1.7 上一直运行良好,改到 1.8.0_65后,就出现了这个问题。
有哪位大侠遇到过此类问题?有请多指教。

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-05-30 10:42
    关注

    要么是配置问题,要么是外部组件兼容性问题
    https://blog.csdn.net/pengchang_1981/article/details/8069124?utm_source=blogxgwz3

    评论

报告相同问题?

悬赏问题

  • ¥15 MapReduce实现倒排索引失败
  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题