• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Sun's Bootstraping Example  RSS feed

 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my problem:
I am trying to recreate the example located here :
Bootstraping Example

I have set up everything to the tutorials specifications, yet I still
get this error :



To resolve this problem, I have followed a topic on JGuru that seemed to encounter the same issue, but we can not fix it using their advice.
Bootstrap Topic

Please help in any way you can. If you have that example up and running,
please reply.

Running out of options,

Zak ( ) and Morgan ( )
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to get the code to run by using either the "good" "use a policy file" approach or the "bad" "override checkPermission in RMIClientBootstrapSecurityManager" approach... which approach did you use?
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, both ways. Can you somehow post all your code and batch files, so I can
try to run them on this side? We are really frustrated, and cannot get this to work.

Thanks

Zak
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of Java are using to run this example ?
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Current status: Still no solution.

We have tried to get the example working in 1.4 and 1.5, but the error is the same. (i.e. Access denied to the classloader).

This is our file structure:

C:\RMI_HTTP
|- server (contains ClassFileServer and ClassServer, also the batch file to run the http server)
|- serve (contains all of the server + client code. Hello,Hello_Impl,MessageObject,RMIClient,RMIServer, and the batch file)
|- client (contains the RMIClientLoadernRMIClientBootstrapSecurityManager)

Also here are my batch files:

Batch for the HTTP Server:


Batch for the RMI Server :


And finally the client bootstrap program:


Now, for my policy files:

C:\\java.policy (basically just modified the JDK's policy file)


We have just about tried everything we can think of. Can anyone help us?

Thanks

Zak
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JDK 1.4 on the machine I got the example to work on.

OK, I'll go through the steps I did to get it to work...

Downloaded all the files into these directories -


Next, edited the RMI_HTTP/runhttp.bat file to point to the RMI_Server directory -


Compiled all code in the RMI_HTTP directory -


Started runhttp.bat in a new terminal window. See -

and the ClassFileServer keeps running.

Now to get the RMI_Server part working.
First, I had to edit the following line into the RMIServerSecurityManager inside the RMIServer.java source file -


Otherwise, when the server runs it throws an AccessException (I'm sure that this could be done using a .policy file, but if we're going to use a SecurityManager with an overridden checkConnect() method, I don't see why an overridden checkAccept() is going to hurt anything.)

OK, now compile the RMI_Server classes and run rmic on the remote interface -


Finished with that, start runserver.bat in a new terminal window, see some log output, and it keeps running...

Now, on to the RMI_Client code.

First, the *bad* way - overridding checkPermission() so there are no security checks.
Edit runclient.bat to use your hostname -


Edit the RMIClientBootstrapSecurityManager.java source to override checkPermission() -


Compile (javac *.java), run (runclient.bat), and voila! everything runs (with no security). You'll see some output in the client terminal and it will complete. The RMI_HTTP and RMI_Server terminals will also display some new log messages.

Now, how to make it work with a policy file -

Remove the changes to the RMIClientBootstrapSecurityManager.java file (if you've made them).

I created a policy file (called "policy" in the RMI_Client directory, with the contents -


Then, I edited the runclient.bat to contain (Note: the following is on multiple lines due to formatting, in reality this is all on one line) -


Again, compile (javac *.java) and run (runclient.bat) and, again it runs (this time with a *teensy, tiny* bit more security).

[ February 08, 2006: Message edited by: Nathan Pruett ]
[ February 09, 2006: Message edited by: Nathan Pruett ]
 
Zak Nixon
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, Nate, great job. We followed your tutorial, and it worked beautifully.

Some changes we saw in your examples need to be made for clarity though.

1. When compiling the RMI_Server classes the command is :

There was a typo stating compiling *.jave files, which is not the case.

2. In the client .bat file (runclient.bat), the policy file flag should be the following :

The trailing .policy was missing.

Other than that, everything seems 100% correct.
Thanks again Nate for your help. It is worth 1 trillion dollars.

Until the next RMI question,

Zak and Morgan
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad that you got it to work!

I went back and fixed the "jave" typo, but the policy file I used was just called "policy" - you can call it whatever you want "Client.policy", "policy", ".policy", "poly.see", "ZAK_ROCKS", "no.name" - as long as it follows your OS file naming conventions. You just have to be sure to use the same name when specifying it in the java.security.policy property.
 
Tamilselvan Guru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent Work... This tutorial saved lot of my time...

Thanks Nate
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!