Question

I'm trying to build rmi-iiop application (very simple chat). I need server to be able to communicate with client so my thinking was to create interface of connected user:

public interface UserInterface extends Remote { 
    public void receiveMessage(String message) throws RemoteException;
}

Then on client side create User class with methods server can execute('receiveMessage'):

public class User extends PortableRemoteObject implements UserInterface {

    protected User() throws RemoteException {
        super();
    }

    @Override
    public void receiveMessage(String message) throws RemoteException {
        client.addMessageToGUI();
    }
}

I use rmic -iiop Chat User which generates _Chat_Tie.class _ChatInterface_Stub.class _User_Tie.class _UserInterface_Stub.class

After placing all files on server side and client side and running the application I get following error: java.rmi.StubNotFoundException: Stub class not found: User_Stub; nested exception is:

I guess the difference here is that Chat class is created on server and then client uses it using interface (which works fine), but user class has to be created on client side, so client works partly as a server.

My question is similar to Java RMI - Making the client a server but for rmi-ioop implementation.

So in to words - how can I send local object reference to server so it could perform operations on it?

Thanks! Leonty

Was it helpful?

Solution 2

What I was missing is "Tie" class on client side (_User_Tie.class). Usually it's not needed but in case when object is created on client side - I needed to supply it also.

Hope it saves some time for someone else in a future :)

OTHER TIPS

you create a server interface like:

public interface ChatServer extends Remote {
  public void registerUser(UserInterface user) throws RemoteException;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top