1

I'm attempting to get a client on one machine to talk to a server on another machine through Java RMI. I deploy the server at host IP X on port Y. I then attempt to get the client to lookup the remote object on the server and I get the following exception:

Exception in thread "main" java.security.AccessControlException: access denied (java.net.SocketPermission <IP address>:<port> connect,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
    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:524)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:189)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at nursestation.NurseStation.subscribeToPatients(NurseStation.java:65)
    at nursestation.NurseStation.<init>(NurseStation.java:42)
    at nursestation.perf.SimplePerfTest.main(SimplePerfTest.java:28)

Note that both the client and server are running with a policy file allowing all permissions. The RMI registry is running on the server as well. Any ideas as to why I'm getting this exception? What can I do to allow the client to talk to a server running on a different server?

Update:

Policy file

grant {
  permission java.security.AllPermission;
};

Client Startup - Using RMI plugin for Eclipse

  1. Start the RMI registry
  2. Executed "java BedsideMonitorMain patient1 vital1 vital2" with the specified policy file for java.security.policy shown above and java.rmi.server.codebase pointing to my project workspace code
  3. The patient1 object is binded to the RMI registry

Server Startup

  1. Executed "java NurseStationMain patient1" with the specified policy file for java.security.policy shown above and java.rmi.server.codebase pointing to my project workspace code
jds2501
  • 136
  • 3
  • 14
  • Are you sure that you're using the policy files correctly? This article http://stackoverflow.com/questions/2427473/java-rmi-accesscontrolexception-access-denied implies that you can get this stacktrace when not having the policy file set correctly. It might be worth editing the question to show the policy files and how you are invoking client and server. – beny23 Nov 08 '11 at 15:34
  • Also make sure your authentication settings are right. Try adding `-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false` to see if it works. – Gray Nov 08 '11 at 15:58
  • Run your client with -Djava.security.debug=access,failure and you will see exactly what permissions are being granted/denied by which protection domains, so you will also see whether your .policy files are in effect, which clearly they aren't. – user207421 Nov 08 '11 at 23:56
  • I'll run that as soon as I can. For now, we've noticed that the remoting works on one of my team member's machine, but not mine. I get the feeling this has to with firewalls possibly? – jds2501 Nov 10 '11 at 16:22

1 Answers1

0

So I figured out the underlying problem. Apparently both machines had a different license key for the Eclipse RMI plugin, which did not allow both machines to communicate with each other. When I made the license key on both machines identical, then I was able to get the client and server to communicate with each other. For my purpose, this is sufficient, as I'm not using this system in a production environment (it's for a class project). I am curious though what the "best" solution would be to this problem.

jds2501
  • 136
  • 3
  • 14
  • 3
    Personally, I can't see what the Eclipse license key would have to do with basic RMI Java connections. Can you explain? – djangofan Nov 12 '12 at 22:14