java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
My server side is working perfectly, no errors on the server.. while when I run my client code, I get this access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve") error.
Please, any expert help me :(
This is my client code
/**
*
* @author saqibhussain
*/
public class ChatClient extends UnicastRemoteObject implements ChatClientIF, Runnable {
public ChatClient() throws RemoteException {
}
private ChatServerIF chat;
private String name = null;
protected ChatClient(String name, ChatServerIF chat) throws RemoteException { this.name = name;
this.chat = chat;
chat.RegisterChatClient(this);
}
public void retrieveMessage(String msg) throws RemoteException {
System.out.println(msg);
}
public void run() {
Scanner scaner = new Scanner(System.in);
String message;
while (true) {
try {
message = scaner.nextLine();
chat.broadcastMessage(name + " : " + message);
} catch (RemoteException ex) {
Logger.getLogger(ChatClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public static void main(String[] args) throws NotBoundException, MalformedURLException, RemoteException {
System.setSecurityManager(new RMISecurityManager());
try {
String url = "rmi://localhost/RMIChatServer";
ChatServerIF remoteObject = (ChatServerIF) Naming.lookup(url);
System.out.println("Got remote object");
new Thread(new ChatClient(args[0], remoteObject)).start();
} catch (Exception e) {
System.out.println(e);
}
}
}