Wednesday, 15 April 2015

java.security.AccessControlException: access denied in Java RMI Telephone Directory -


I have found this source on the Internet for my academic assignment purpose. This is just a practical of Java RMI here I am posting the code of my server file.

  Import java.io. *; Import java.util. *; Import java.rmi *; Import java.rmi.server. *; Public Square LookupServer UnicastRemoteObject implies lookup {save private vector = new vector (); Public Lookup Server (String DB) throws remote exposure {try {FileReader fr = new FileReader (db); Buffett reader BR = new buffed reader (FR); String s = null; While ((s = br.readline ()) = = null save.addElement (s); fr.close ();} hold (throbable e) {System.err.println ("Explain in lookupserrer ():" + e ); System.exit (1);}} public string searchInfo (string information) {if (info == null) return null; info = info.toLowerCase (); int n = save.size (); (int = 0; String DBS = (string) save for the I & lt; n; i ++) .mentment (i); If (dbs.toLowerCase (). IndexOf (info)! = -1) Return DBS;} Return Null;} Public Stable Zero Main (String Array []) {try {RMISecurityManager security = new RMISecurityManager (); System.setSecurityManager (Security); String DB = Args [0]; Lookup Server = New Lookup Server (DB); Naming. Ribind ("Lookup Server", Server); System.err.println ("Lookup Server Ready ...");} Hold (Throwable E) {System.err.println ("Exception in main:" + E); System.exit (1);}}}  

My policy file (policy.policy) contains < / P>

  grant {// Allow everything to allow java.security.AllPermission;};  

Now I'm stuck:

< P> C: /> Java Lookup Server Database. Txt java.security.policy = policy.policy

Exception key in: java.security.AccessControlException: Access denied (java.net.SocketPermission 127.0.0.1:1099 connect, resolution)

Please help me ...!

Code> C: /> Java-Dajava.security.policy = policy.policy lookup server database. Txt

No comments:

Post a Comment