CalculationServerRegistrationService server = new CalculationServerRegistrationService();
ICalculationServerRegistrationService stub = (ICalculationServerRegistrationService) UnicastRemoteObject.exportObject(server, RMI_PORT);
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry();
registry.bind("ICalculationServerRegistrationService", stub);
new RMIServerTimeoutChecker().run();
}
當我在同一臺機器上啓動rmiregistry的命令不帶參數,但裏面d:/ git的/ nnCloud/BE/nnCloudRESTService /目標/ classes文件夾,一切工作正常。但是,由於我需要兩個來自不同程序的服務器,因此我希望具有兩個代碼庫的單個rmiregistry,因此需要明確指定它,而不是在不同目錄中運行兩個「rmiregistry」命令。無法啓動RMI服務器時使用的代碼庫
我看到的唯一解決方案是運行
rmiregistry中-J-Djava.rmi.server.codebase =「文件:/ d:/ GIT中/ nnCloud/BE/nnCloudRESTService /目標/類文件中:/D:/ git/nnCloud/BE/nnCloudRESTService/target/classes「
這樣做後,我的應用程序崩潰在registry.bind。
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.mycompany.nncloudrestservice.serverservice.ICalculationServerRegistrationService
你有一個ClassNotFoundException後;最有可能的是,在你的一個設置中,**類路徑**不是它應該的。 – GhostCat