Reputation: 5092
I'm writing a client-server program with Java RMI and I'm getting an error:
java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
My code looks like this:
package xxx;
import java.rmi.Naming;
import java.rmi.RemoteException;
public class Server extends Engine implements RemoteInterface {
public Server() {
super();
if(System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
Naming.rebind("Test", this);
System.out.println("Bound in registry!");
} catch(Exception ex) {
System.out.println(ex);
}
}
@Override
public void test() throws RemoteException {
System.out.println("test() invoked");
}
}
What's wrong?
Upvotes: 0
Views: 4496
Reputation: 5092
I had forgot to add the registry and to implement Serializable. Problem solved. I also removed the SecurityManager.
Upvotes: 1
Reputation: 311046
You have installed a SecurityManager but you haven't granted yourself enough permissions to execute this code.
Why do you think you need a SecurityManager at all? Unless you are planning to run uploaded code I would just get rid of it
Upvotes: 0