未经本人许可,不得转载该文!
错误描述:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: compute.ComputeEngine (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 connection.RMIConnect.run(RMIConnect.java:128)
at java.lang.Thread.run(Thread.java:722)
解决方法:
按步骤执行以下方法:
1. 在你的客户端绑定端口时,添加以下代码。
try {
System.setSecurityManager(new java.rmi.RMISecurityManager());
remote = (Compute) Naming.lookup("rmi://localhost:1099/zhaopeng");
} catch (RemoteException ex) {
Logger.getLogger(RMIConnect.class.getName()).log(Level.SEVERE, null, ex);
} catch (NotBoundException ex) {
System.out.println("waiting bound....");
} catch (MalformedURLException ex) {
System.out.println(ex.getMessage());
}
2.编译时,连接policy文件
java -Djava.security.policy=client_policy.txt <你的客户端,例如europeanproject.GUIFrame>
注意: client_policy.txt
grant{
permission java.security.AllPermission;
};
3. 解决问题了!
不要听信网上乱七八糟的解决方法,这个80%都行!