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.code开发者_如何学JAVAbase=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?
Problem solved.
The server.policy file was wrong the correct is this:
grant { permission java.net.SocketPermission "*:1024-", "connect,accept"; permission java.security.AllPermission; };
精彩评论