RMI问题通过java.rmi.ServerException继续

时间:2017-10-10 23:09:05

标签: java rmi classnotfoundexception

我的代码抛出错误:RMI服务器到达某个点然后:

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)

我正在使用eclipse编译安装了RMI插件。

我的服务器RMI代码:

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.");
    }
}

0 个答案:

没有答案