2011-02-15 227 views
0

當我啓動的RMIServer實現類它顯示此錯誤消息RMI拋出java.lang.ClassNotFoundException:RMIServerImpl_Stub

Remote exception: java.rmi.ServerException: RemoteException occurred in server t 
hread; nested exception is: 
     java.rmi.UnmarshalException: error unmarshalling arguments; nested excep 
tion is: 
     java.lang.ClassNotFoundException: RMIServerImpl_Stub 

命令跑

開始rmiregistry中

開始的java -Djava.security.policy = policyfile RMIServerImpl

我該怎麼做才能解決這個問題。請幫助

這是我的RMI服務器的代碼

import java.rmi.*; 
import java.rmi.server.*; 
import java.rmi.registry.*; 

公共類的RMIServerImpl擴展了UnicastRemoteObject 實現的RMIServer {

RMIServerImpl() throws RemoteException { 


    super(); 
} 


public static void main(String args[]) { 


    try { 
     System.setSecurityManager(new RMISecurityManager()); 

     RMIServerImpl Server = new RMIServerImpl(); 


     Naming.rebind("SAMPLE-SERVER", Server); 

     System.out.println("Server waiting....."); 
    } catch (java.net.MalformedURLException mue) { 
     System.out.println("Malformed URL: " + mue.toString()); 
    } catch (RemoteException re) { 
     System.out.println("Remote exception: " + re.toString()); 
    } 

} 

}

回答

0

聽起來像是你沒有運行rmic編譯生成存根和骨架。

自從我手工完成原始RMI以來,這已經很長時間了,我不知道是否仍然需要這一步驟。但這是我最後一次執行RMI。

如果你確實運行了rmic,那麼我猜你沒有將存根和骨架與服務器端和客戶端正確打包。如果您可以找到這些.class文件,請檢查您的打包和部署。

+0

我跑這個存根類是存在的。在我的java代碼中沒有包語句。我能做什麼 ? – user602774 2011-02-15 03:28:43