我正在通过 RMI 连接的应用程序开发两个。通信是双向的,一切正常,直到我在 Windows 上运行。当我将 jar 文件带到 Debian 时,连接失败并显示java.rmi.NoSuchObjectException
.
知道 linux 有什么不同或为什么它不工作吗?
编辑:我的代码:
服务器端:
static Registrator clientRegistrator = null; // static field, interface extending java.rmi.Remote
...
Registry rmiRegistry = LocateRegistry.createRegistry(RmiConstants.RMI_REGISTRY_PORT);
clientRegistrator = (Registrator) UnicastRemoteObject.exportObject(new RmiClientRegistrator(networkListeners), RmiConstants.RMI_REGISTRY_PORT); // RmiClientRegistrator implements Registrator interface
rmiRegistry.bind(RmiConstants.RMI_SERVER_MARK, clientRegistrator);
客户端:
static Registrator serverRegistrator = null;
String rmiConnectionString = "rmi://localhost:" + RmiConstants.RMI_REGISTRY_PORT + "/" + RmiConstants.RMI_SERVER_MARK;
serverRegistrator = (Registrator) Naming.lookup(rmiConnectionString);
serverRegistrator.registerClient(dataReceiver); // fails here, with mentioned exception