2

i m trying to use rmi. The code below is the code that i m using it to bind.

    @Override
    public void init(String serviceName) throws RemoteException {
    /*if(System.getSecurityManager() == null){
        System.setSecurityManager(new RMISecurityManager());
    }*/
    try {
        String host = InetAddress.getLocalHost().getHostName();
        String url = "rmi://"+ host + "/"+ serviceName;
        //String url = "//localhost/" + serviceName;
        Naming.rebind(url,this);
    } catch (UnknownHostException e) { 
        e.printStackTrace();
    } catch (MalformedURLException e) { 
        e.printStackTrace();
    }
}

no matter which url i use i m getting the exception below. It never finds the class to marshall. Can someone help me about this issue. Thanks in advance.

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
java.lang.ClassNotFoundException: ceng443.hw3.base.SocialNetworkServer
4

1 回答 1

0

您需要一个安全管理器才能使用 RMI 下载任何代码,但您已在发布的片段中将其注释掉。您可以尝试取消注释您的安全管理器设置吗?

于 2011-12-31T18:05:43.973 回答