在 Java 中运行 RMI 应用程序时出现问题
我正在关注有关 Java RMI 的教程 http://download.oracle.com/javase /tutorial/rmi/TOC.html
但是,当我尝试启动服务器时,我收到以下错误:
ComputeEngine 异常: java.security.AccessControlException:访问被拒绝(java.net.SocketPermission 127.0.0.1:1099 连接,解析) 在 java.security.AccessControlContext.checkPermission(来源未知) 在 java.security.AccessController.checkPermission(来源未知) 在 java.lang.SecurityManager.checkPermission(来源未知) 在 java.lang.SecurityManager.checkConnect(来源未知) 在 java.net.Socket.connect(来源未知) 在 java.net.Socket.connect(来源未知) 在 java.net.Socket.(来源不明) 在 java.net.Socket.(来源不明) 在 sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(来源未知) 在 sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(来源未知) 在 sun.rmi.transport.tcp.TCPEndpoint.newSocket(来源未知) 在 sun.rmi.transport.tcp.TCPChannel.createConnection(来源未知) 在 sun.rmi.transport.tcp.TCPChannel.newConnection(来源未知) 在 sun.rmi.server.UnicastRef.newCall(来源未知) 在 sun.rmi.registry.RegistryImpl_Stub.rebind(来源未知) 在 engine.ComputeEngine.main(ComputeEngine.java:61)
我尝试使用以下命令运行:
D:\files\develop\javarmi>java -cp D:\files\develop\javarmi;D:\files\webdocs \classes\compute.jar -Djava.rmi.server.codebase=文件:/D:/files/webdocs/classes/compute.jar -Djava.rmi.server.hostname=192.168.0.162 -Djava.security.policy=server.policy engine.ComputeEngine
我应该如何解决此问题?
I am following this tutorial about Java RMI http://download.oracle.com/javase/tutorial/rmi/TOC.html
However when I try to start the server I receive the following error:
ComputeEngine exception:
java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:61)
I am trying to run with the following command:
D:\files\develop\javarmi>java -cp D:\files\develop\javarmi;D:\files\webdocs\classes\compute.jar -Djava.rmi.server.codebase=file:/D:/files/webdocs/classes/compute.jar -Djava.rmi.server.hostname=192.168.0.162 -Djava.security.policy=server.policy engine.ComputeEngine
What should I do to correct this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。
server.policy 文件错误正确的是:
grant {
权限 java.net.SocketPermission "*:1024-", "连接,接受";
权限 java.security.AllPermission;
};
Problem solved.
The server.policy file was wrong the correct is this:
grant {
permission java.net.SocketPermission "*:1024-", "connect,accept";
permission java.security.AllPermission;
};