Search This Blog

Monday, October 17, 2011

Java.Security.AccessControlException ERROR IN RMI PROGRAMMING

These errors are related to the security policy of java
Java has it's own security manager that takes care of all unprivileged connection accesses.
To resolve these kinds of errors ,you need to create a new security policy 



Eg. For allowing connections to ip 127.0.0.1 at pot 1099 and 1024

grant{
permission java.net.SocketPermission "localhost:1099", "connect, resolve";
permission java.net.SocketPermission "localhost:1024-", "connect, resolve";
permission java.net.SocketPermission "localhost:1024-", "accept, resolve";

permission java.net.SocketPermission "localhost:1099-", "accept, resolve";
};


Save the content in a file called policy.txt and now run your server as



java -Djava.security.policy=policy.txt Server


The policy file must be saved in same folder where you have saved Server.java