rmi - Error in main - java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve") -
this question has reply here:
java rmi accesscontrolexception: access denied 2 answersi've been trying run rmi illustration have been getting above error on both linux , windows. have seen people same problem online in different situations.
my server class is:
import java.rmi.*; import java.rmi.server.*; public class cityserverimpl extends unicastremoteobject implements cityserver { cityserverimpl() throws remoteexception { super(); } public string getcapital(string country) throws remoteexception { system.out.println("sending homecoming string - country requested: " + country); if (country.tolowercase().compareto("usa") == 0) homecoming "washington"; else if(country.tolowercase().compareto("ireland") == 0) homecoming "dublin"; else if (country.tolowercase().compareto("france") == 0) homecoming "paris"; homecoming "don't know one!"; } public static void main(string args[]) { seek { system.setsecuritymanager(new rmisecuritymanager()); system.out.println("security manager set"); cityserverimpl cityserver = new cityserverimpl(); system.out.println("instance of city server created"); naming.rebind("capitals", cityserver); system.out.println("name rebind completed"); system.out.println("server ready requests!"); } catch(exception exc) { system.out.println("error in main - " + exc.tostring()); } } }
i set interface, cityserver class , client class folder , set next terminal.
javac -cp . *.java rmic cityserverimpl rmiregistry & java cityserverimpl
and back:
security manager set instance of city server created error in main - java.security.accesscontrolexception: access denied ("java.net.socketpermission" "127.0.0.1:1099" "connect,resolve")
the 'naming.rebind("capitals", cityserver);' appears problem. have found mentions of policy file have been told should run fine without one. both client , server running on same pc. thought on how around this?
you defined rmisecuritymanager
, did not grant permissions execute code. can define policy specified here , pass in 1 of 2 ways.
<path>
set code system.setproperty("java.security.policy","<path>");
i recommend reading this tutorial oracle.
this should duplicate of old question.
java rmi
No comments:
Post a Comment