0

I have the folloving RMI server:

public static void main(String[] args) {
    try{
        ChatSystemImpl chatSystem = new ChatSystemImpl();
        ChatSystem chatSystem_stub = (ChatSystem) UnicastRemoteObject.exportObject(chatSystem, 6001);

        Registry registry = LocateRegistry.getRegistry("localhost", 6001);
        registry.bind("ChatSystem1", chatSystem_stub);

        System.out.println("Server up.");
    }
    catch(Exception ex){
        ex.printStackTrace();
    }
}

When I run it I get:

ava.rmi.NoSuchObjectException: no such object in table
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
    at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
    at fr.inp.ensimag.examples.chatsystem.Main.main(Main.java:30)

Well I have no idea whats wrong... Staring on it for more then 2 hours right now.

This is the interface (if needed):

public interface ChatSystem extends Remote{
    void registerUser(UserInfo newUser) throws RemoteException;
    void unregisterUser(UserInfo user) throws RemoteException;
    boolean userExists(UserInfo user) throws RemoteException;
    void send(MessageInfo message) throws RemoteException;
}

The implementation has following header, the body just contains methods that are not really implemented, they just thow UnsupportedOperationException :

public class ChatSystemImpl implements ChatSystem

The ChatSystem interface is in other project then the rest of source code if it is of any importance.

Thank you.

Rasto
  • 17,000
  • 40
  • 141
  • 232

1 Answers1

0

Your Registry has been unexported. This usually means that you are running it in a JVM via LocateRegistry.createRegistry() and you have let it become garbage-collected. The result of that method should be stored in a static variable. It may also mean that you never started the Registry in the first place.

user207421
  • 289,834
  • 37
  • 266
  • 440