无法在Java中运行RMI应用程序

时间:2011-05-26 18:54:24

标签: 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 connect,resolve)     at java.security.AccessControlContext.checkPermission(Unknown Source)     at java.security.AccessController.checkPermission(Unknown Source)     在java.lang.SecurityManager.checkPermission(未知来源)     在java.lang.SecurityManager.checkConnect(未知来源)     在java.net.Socket.connect(未知来源)     在java.net.Socket.connect(未知来源)     在java.net.Socket。(未知来源)     在java.net.Socket。(未知来源)     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)     在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 = file:/ D: /files/webdocs/classes/compute.jar -Djava.rmi.server.hostname = 192.168.0.162 -Djava.security.policy = server.policy engine.ComputeEngine

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:2)

问题解决了。

server.policy文件错误,正确的是:

授予{ 权限java.net.SocketPermission“*:1024-”,“connect,accept”; permission java.security.AllPermission; };