【发布时间】:2016-10-23 12:32:17
【问题描述】:
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();
}
当我在没有参数但在 D:/git/nnCloud/BE/nnCloudRESTService/target/classes 文件夹中的同一台机器上启动 rmiregistry 命令时,一切正常。但是,由于我需要来自不同程序的两台服务器,我希望拥有一个带有两个代码库的 rmiregistry,因此需要明确指定它,而不是在不同的目录中运行两个“rmiregistry”命令。
我看到的唯一解决方案是运行
rmiregistry -J-Djava.rmi.server.codebase="file:/D:/git/nnCloud/BE/nnCloudRESTService/target/classes 文件:/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;这很可能意味着在您的一种设置中,classpath 不是应有的样子。