簡體   English   中英

使用rmi時的編組問題

[英]Marshalling issue while using rmi

我試圖使用RMI。 下面的代碼是im使用它進行綁定的代碼。

    @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();
    }
}

無論我使用哪個URL我都會在下面獲取異常。 它永遠找不到要編組的班級。 有人可以幫我解決這個問題。 提前致謝。

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

您需要一個安全經理才能使用RMI下載任何代碼,但是在發布的片段中已將其注釋掉。 您可以嘗試取消對securitymanager設置的注釋嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM