English 中文(简体)
Java RMI - Socket Permission issues
原标题:

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.

最佳回答

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 :)

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签