I have been learning more about Java RMI, but I am running into some obstacles, and I am hoping that some of my readers can help me figure these obstacles out.
I have managed to get a sample Java RMI application running, as long as I start the RMI server and client from the DOS shell with something like this for the server:
java -cp .;c:\tomcat5\webapps\rmi\compute.jar -Djava.rmi.server.codebase=file:/c:\tomcat5\webapps\rmi\compute.jar -Djava.security.policy="C:\\tomcat5\\webapps\rmi\server.policy" engine.ComputeEngine
and this for the client:
java -cp c:\tomcat5\webapps\rmi;c:\tomcat5\webapps\rmi\compute.jar
-Djava.security.policy="c:\\tomcat5\\webapps\\rmi\\client\\client.policy" client.ComputePi localhost %1%
You will notice that I am storing many of the components in the Tomcat directory, but Java RMI does not actually require Tomcat. (This is actually something of a virtue.) I can make it work with Tomcat stopped.
However, if I try to get this running from MyEclipse, with all the magic incantations (environment variables for the -D fields, for example), I cannot get either the server or the client to work. The error message for the server is:
java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
This is apparently tied to the security policy settings. My guess is that there is something rather magical about how MyEclipse is setting up the java.security.policy environment variable that explains the misbehavior: perhaps the use of backslashes in the DOS shell has to be done differently from MyEclipse. I've tried a variety of different forms of this, without success. It also looks like perhaps the security policy might require a URL, so I tried file:/// before the file name, without success.
Perhaps there is some way to force MyEclipse to show you what parameters it is passing to java when it executes?
What is a bit annoying is that you can find vast numbers of questions on the Internet from developers running into exactly this same problem -- but real answers are surprisingly difficult to find.