RMI question

I tested the RMI examples in book Java Network rogramming (Manning, ISBN 0-13841-206-5).  I followed the steps in the book to build rmi server and client.  however, I only could run the server in jdk1.1, if I used jdk1.2, I got an exception:

exception in thread "main" java.security.AccessControlException: access enied (java.net.SocketPermission 127.0.0.1: 1099 connect, resolve)
.........

what does it mean?

Thanks
embertAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ravindra76Connect With a Mentor Commented:
Hi embert,

1. Find java.policy in your system.

  Replace the text in it with the following code.

grant {
      // Allow everything for now
      permission java.security.AllPermission;
};

0
 
embertAuthor Commented:
Edited text of question.
0
 
Ravindra76Commented:
Hi embert,

 The new extended security model was defined in Java1.2 which will disallow socket permisiions to connect and resolve . In java.policy, initially all are set to defaults which will cause so many security exceptions if you are doing some sensible operations like creating a socket and listening on some port like operations.

So we have to change the default permisions to work our code with cost of reducing some level of security.

You will get all these details in this URL.

http://www.eurocom.od.ua/~sasha/books/java/JavaUnleashed_1.2/ch03/ch03.htm

Enjoy a lot.

Best of luck
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
embertAuthor Commented:
there are several copies of java.policy, in which I should make the change?

thanks,
0
 
Ravindra76Commented:
Hi embert,

 Put one file backup.
 Change all the java.policy files.
 It will be present in two locations only.

 One in drivename\jdkhome\JRE\lib\security
 Eg: c:\jdk121\hre\lib\security

drivename\program files\javasoft\jre\1.2\lib\security

Eg:c:\program files\javasoft\jre\1.2\lib\security.

First change these two files.

In my system only these two copies are persent.

IF it did n't work, replace all.

But put one back up copy

Best of luck
0
 
embertAuthor Commented:
I just replaced the java.policy file in c:\jdk121\hre\lib\security, and it worked fine.

Thanks!
0
 
vikas0857Commented:
create a policy file called  filename.policy where filename is any permitted name .

copy the following code and pasted it there

grant
{
permission java.net.SocketPermission *:1099","connect,accept";
permission java.security.AllPermission;

};

then after compiling your program typr the following in your command line .

java -Djava.security.policy=filename.policy YourAppl

where YourAppl is the class after compilation.

0
 
kodiakbearCommented:
Fixed the -1 problem on this question.
Escrow points corrected.

kb
Community Support Moderator
Experts Exchange
0
All Courses

From novice to tech pro — start learning today.