问题
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 ?
EDIT: 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
回答1:
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.
The surest remedy against this is to keep a static reference to the remote object in the JVM it was exported from.
回答2:
Did you see here:
java.rmi.NoSuchObjectException: no such object in table
Java RMI NoSuchObjectException
and here:
A NoSuchObjectException is thrown if an attempt is made to invoke a method on an object that no longer exists in the remote virtual machine. If a NoSuchObjectException occurs attempting to invoke a method on a remote object, the call may be retransmitted and still preserve RMI's "at most once" call semantics. A NoSuchObjectException is also thrown by the method java.rmi.server.RemoteObject.toStub and by the unexportObject methods of java.rmi.server.UnicastRemoteObject and java.rmi.activation.Activatable and
来源:https://stackoverflow.com/questions/14501873/java-rmi-nosuchobjectexception-on-linux