Posted By:
Sakibul_Khan
Posted On:
Tuesday, April 23, 2002 10:38 PM
There is nothing wrong with your program, only that you are not RUNNING
it with the proper option.
You need to add a POLICY file, that specifies the correct Security option
Use the "policytool" that JDK provides to create the policy file OR you
can copy & paste my one. I am giving you the one that I always use:-
------------------------------------------------------------------------------------
grant {
permission java.net.SocketPermission "*:1024-65535", "connect,accept,resolve";
permission java.net.SocketPermission "*:80", "connect";
};
-------------------------------------------------------------------------------------
[N.B. if you get a RUNTIME error stating CANNOT parse policy file,
then it means that you did not write your policy file in the right way.
Hence, I would recomend you to use the "policytool" of JDK, which will
automatically create the policy file in your ROOT directory (for UNIX) OR
the C:Windows dir of Win]. By the way Don't add the dotted lines
Now save the above lines in any file like "myfile.policy", then when you run
your RMI program add the following line in the command line option
that you are currently using:-
-Djava.security.policy=myfile.policy
eg. If previously you were using
java -Djava.rmi.server.codebase=http://www.cs.mcgill.ca/~skhan20/cs/577/ myRMICLIENT 4000
then add the security option & it will become like this:-
java -Djava.rmi.server.codebase=http://www.cs.mcgill.ca/~skhan20/cs/577/ -Djava.security.policy=myfile.policy myRMICLIENT 4000
In my example, 4000 is just a port # that I am mentioning from the command
prompt, you can also hard-code the port # in both of your RMISERVER
& RMICLIENT.
Also, I have always added the policy files in both my
RMIservers & RMIclients. I know it is a MUST for RMIclients, but your program
may still work fine even if you DONT mention the policy file with your server.
If you still have problems, look in to the following file:-
http://www.cs.mcgill.ca/~skhan20/cs/utils_j/RMIsimpleexample.htmlthe example in here is short, simple & to the point. It tells you STEP by STEP the
procedures of how to install the RMISERVER & then connect a RMICLIENT
to it.