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

未经本人许可,不得转载该文!


错误描述:

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

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值