Java RMI NoSuchObjectException [英] Java RMI NoSuchObjectException
问题描述
我有一个使用Java RMI的服务器和客户端.如果我使用一个客户端,那么使用下面的代码就可以了.但是,如果我先连接一个客户端,然后再连接第二个客户端,则会抛出已在使用中的端口异常.很好,所以我断开连接的客户端的连接,然后尝试再次与第二个客户端连接.它给了我这个:
I have a server and client using Java RMI. If I use one client all is fine with the code below. But if I connect with a client and then a second one, it throws port already in use exception. That's fine, so I disconnect the connected client and then try to connect with the second client again. It gives me this:
java.rmi.NoSuchObjectException:表中没有此类对象
java.rmi.NoSuchObjectException: no such object in table
这是为什么?
//CONNECT
Registry registry = LocateRegistry.getRegistry(
Options.getRegistryIp(), Options.getRegistryPort());
server = (IServer) registry.lookup(Constants.MB_SERVER_NAME);
UnicastRemoteObject.exportObject(client, Options.getMyPort());
server.registerClient(client);
//DISCONNECT
server.removeClient(client, client.getUser());
UnicastRemoteObject.unexportObject(client, false);
推荐答案
NoSuchObjectException意味着存根引用已显式或通过GC取消导出的远程对象.您是在lookup()还是registerClient()还是removeClient()上获取此信息的?
NoSuchObjectException means that the stub refers to a remote object which has been unexported, either explicitly or via GC. Are you getting this on the lookup(), or the registerClient(), or the removeClient()?
这篇关于Java RMI NoSuchObjectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!