但是当我将我的项目分成两个项目(客户端和服务器)时,请查看屏幕截图:
这里,当我运行服务器时,它可以工作,但是当我运行客户端时,它会显示以下错误:
Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: server.i_object (no security manager: RMI class loader disabled)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
at client.Main_client.main(Main_client.java:24)
Caused by: java.lang.ClassNotFoundException: server.i_object (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:554)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:257)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1549)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1511)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
... 3 more
Java Result: 1
问题是什么?
答案 0 :(得分:0)
它说:
没有安全管理器:禁用了RMI类加载器
RMI需要安全管理器才能运行。
示例:
http://www.coderanch.com/t/459111/java/java/no-security-manager-rmi-class
<强>更新强> 这篇link讨论了RMI中的安全性
答案 1 :(得分:0)
对我来说有用的是在每个项目服务器和客户端中使用相同包名称的包中制作接口的副本