简体   繁体   中英

Marshalling issue while using rmi

im trying to use rmi. The code below is the code that im 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 im 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

You need a securitymanager in order to download any code using RMI, but you have it commented out in the fragment you posted. Can you try uncommenting your securitymanager setup?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM