因此,我使用了 LocateRegistry.createRegistry()
,但这有一个问题:即,它在调用它的进程内运行,因此,如果我使用多个 JVM,那么启动注册表的 JVM 崩溃将导致所有 JVM 的注册表崩溃。
所以看起来我需要使用 rmiregistry (或其他东西?)来隔离从服务器 JVM 进行 RMI 查找/绑定(bind)的进程。
我尝试这样做,现在当我尝试执行 Registry.rebind()
时收到此错误:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: {my remote interface name}
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
我做错了什么?我用谷歌搜索了这个异常,它与 RMI 代码库有关,但我真的迷失了这里。如果问题出在 rmiregistry
命令中,那么有哪些命令行选项可以告诉它该怎么做?如果问题出在我的服务器 JVM 中,我需要做什么?
最佳答案
什么崩溃?我已经很多年没有见过 JVM 崩溃了。除非您有 JNI,否则包含 RMI 服务器的 JVM 不会比 rmiregistry 命令启动的独立 JVM 更容易崩溃。使用 LocateRegistry.createRegistry() 可以永远解决您的类路径问题。
关于java:rmiregistry设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5682556/