0

My code is throwing an error: the RMI server gets to a point and then:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
java.lang.ClassNotFoundException: helloworld.MessageImpl_Stub
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:460)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)

I am using eclipse to compile with RMI plug-in installed.

My server RMI code:

package helloworld;

import java.rmi.Naming;
import java.rmi.RemoteException;

public class HelloRMIServer {

    // TODO 08. Set the OBJECT_NAME to the same value used by the client.
    @SuppressWarnings("unused")
    private static String OBJECT_NAME = "TEST";

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

    public static void main(String[] args) {
        try {
            String URL = "rmi://" + "localhost" + "/";

            // TODO 09. Create a new instance of the remote object.
            MessageImpl OBJECT_NAME = new MessageImpl();
            System.out.println("CODE GETS THIS FAR");
            //MessageImpl message = (MessageImpl)Naming.lookup(URL);
            // TODO 10. Re-bind the object in the registry.
            Naming.rebind(URL, OBJECT_NAME);
            System.out.println("Server object message bound into registry.");
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Server done creating and binding objects.");
    }
}
user207421
  • 305,947
  • 44
  • 307
  • 483
Cameron2222
  • 41
  • 1
  • 7
  • One extra note, when I run rmiregistry in eclipse it says "Your environment has the CLASSPATH variable set. It will be unset for the RMI registry process that you're about to start. Starting the registry with no CLASSPATH and configuring the codebase property for your server applications is recommended. – Cameron2222 Oct 10 '17 at 23:10
  • Check this https://stackoverflow.com/questions/9531158/java-rmi-serverexception-remoteexception-occurred-in-server-thread-classnotfou – Sergei Sirik Oct 10 '17 at 23:15
  • 1
    Executive summary: change it to `super(0);`. NB Your final `println()` is in the wrong place. Should be inside the `try` block: otherwise it's a lie. – user207421 Oct 10 '17 at 23:38

0 Answers0