views:

305

answers:

1

Hi,

I'm having problems trying to connect my java program to 2 different sockets. Basically I want to initialise my RMI Server (connecting to port 1099) and then also initialise PrologBeans on port 10002. The initialisation seems to work fine for both, but as soon as I try to access the prologBeans I get the following error:

Exception in thread "main" java.security.AccessControlException: access denied 

    (java.net.SocketPermission 127.0.0.1:10002 connect,resolve)
 at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
 at java.security.AccessController.checkPermission(AccessController.java:546)
 at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
 at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
 at java.net.Socket.connect(Socket.java:519)
 at java.net.Socket.connect(Socket.java:475)
 at java.net.Socket.<init>(Socket.java:372)
 at java.net.Socket.<init>(Socket.java:186)
 at se.sics.prologbeans.PrologSession.connectToServer(PrologSession.java:511)
 at se.sics.prologbeans.PrologSession.initSend(PrologSession.java:442)
 at se.sics.prologbeans.PrologSession.send(PrologSession.java:368)
 at se.sics.prologbeans.PrologSession.executeQuery(PrologSession.java:331)
 at api.ActionRetriever.logEvent(ActionRetriever.java:68)
 at contract.ContractManager.log_event(ContractManager.java:87)
 at gui.RMITrial.main(RMITrial.java:39)

I also have a policy file (in the package where my RMI code is. Is this even the correct place to place the policy file or should it be in the default package?), which is set to:

grant {
permission java.security.AllPermission;};

I was wondering if anyone has any idea on why I'm getting the SocketPermission error? Is my permission settings wrong?

Any help would be much appreciated.

Thanks.

A: 

You need to include the VM argument -Djava.security.policy=path/to/policy/file... and then your policy file should be read and all shall be fine :)

Aly