RMI [java.rmi.UnmarshalException] 问题解决

来源:互联网 发布:psp看书软件羊皮纸 编辑:程序博客网 时间:2024/05/01 22:34

错误描述:

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%都行!

0 0
原创粉丝点击