我是 RMI 新手
我试过这个例子。这按预期工作。
Calculator.class
CalculatorImpl.class + CalculatorImpl_Stub.class
CalculatorServer.class
+
CalculatorClient.class
实际上,我打算在两台不同的 PC 上对其进行测试。但不是那样,我开始在同一台 PC 的两个不同文件夹中尝试它。
一个文件夹包含服务器:
Calculator.class :interface
CalculatorImpl.class + CalculatorImpl_Stub.class
CalculatorServer.class
另一个文件夹包含客户端:
Calculator.class :这只是 CalculatorClient.class 上面服务器的 Calculator 接口的
副本
当我尝试运行的东西服务器运行良好
现在,当我运行客户端时,会打印此错误:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: CalculatorImpl_Stub (no security manag
er: RMI class loader disabled)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at CalculatorClient.main(CalculatorClient.java:12)
Caused by: java.lang.ClassNotFoundException: CalculatorImpl_Stub (no security ma
nager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 3 more
- 它们在同一个文件夹中运行良好。
- 当它们位于两个不同的文件夹中时出错。
为什么?
如何解决此错误?