aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Restrictions on RMI - what does that mean to me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Restrictions on RMI - what does that mean to me?" Watch "Restrictions on RMI - what does that mean to me?" New topic
Author

Restrictions on RMI - what does that mean to me?

oli mueller
Ranch Hand

Joined: Feb 13, 2011
Posts: 42
Hi,
for my URLYBird i have the following RMI restrictions:

(a) you must not require a HTTP server
(b) you must not require the installation of a security manager
(c) you must provide all classes pre-installed so that no dynamic class downloading occurs.

(1)The most interesting one is req. c - if I understand this correctly, I must run rmic to generate the stub/skeleton class files- is this correct??..if so, I have a problem - because in my java 1.5 jdk there is no rmic anymore!!!....

(2) After testing every single availabe rmi tutorial on the web, i finally managed to make one running...lol...this is how the server registers the object:



To run it i must provide a property: -Djava.rmi.server.codebase=file:C:\temp\RMIHelloWorld\bin\


IS THIS APPROACH feasible for the certificate??....I mean most likely the sun-guys do not want to specify some code base...., but how can i avoid this...?..

Thanks...
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

This doesn't answer your question. But here's an example on RMI that I managed to get working http://www.coderanch.com/t/529290/java/java/Classpath . Might be of some use.


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5545
    
  13

Hi oli,

(1) My JDK 1.6.0_16 installation has a rmic tool, the jre installation has not. I generated my stubs (see the ant build script in ScjdFaq). Roberto Perillo passed without generating these files (and he documented his decision in choice.txt)

(2) Indeed you are not allowed to provide extra command line arguments when executing the jar file. My code to run the rmi server and registering my business service implementation is similar to the code snippet you provided. And I simply use the command java -jar runme.jar server to start the application in server mode, no additional arguments/options necessary.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
oli mueller
Ranch Hand

Joined: Feb 13, 2011
Posts: 42
Hi,

thank you for reply...i played a bit around and I found out that IF I start the rmiregistry from the folder in which my classes are, I do not need to specify the codebase with a VM argument...

..this actually leads me to another question: (1) is it correct, that you MUST start the rmiregistry (in a separate cmd window) before you start the server program (or have you started the rmiregistry somehow inside your source code..) (2) if i am correct that you need to start "rmiregistry" manually, I wonder if the sun-people really start it from the right folder, because if they dont they would probably get the same ClassNotFoundExceptions that i am getting...which would be a bad thing....for me...

thanks.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5545
    
  13

I don't start the RMI registry through the tool rmiregistry. Maybe you should have a closer look to the class LocateRegistry, it might have some method to create an rmi registry for you...
oli mueller
Ranch Hand

Joined: Feb 13, 2011
Posts: 42
hi nils,

ok, thanks for the hint...I will have a look....
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5545
    
  13

oli mueller wrote:hi nils,

Who is nils
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

oli mueller wrote:Hi,

thank you for reply...i played a bit around and I found out that IF I start the rmiregistry from the folder in which my classes are, I do not need to specify the codebase with a VM argument...


I think that starting the rmiregistry from the folder that contains your classes is not the recommend approach.

Read this example here. In particular this extract:

Note: Before you start the rmiregistry, you must make sure that the shell or window in which you will run the registry either has no CLASSPATH set or has a CLASSPATH that does not include the path to any classes that you want downloaded to your client, including the stubs for your remote object implementation classes.

If you start the rmiregistry, and it can find your stub classes in its CLASSPATH, it will ignore the server's java.rmi.server.codebase property, and as a result, your client(s) will not be able to download the stub code for your remote object. For an explanation of how code downloading works in RMI, please take a look at the tutorial on Dynamic code downloading using RMI.


And this extract here:

Note: A stub class is dynamically downloaded to a client's virtual machine only when the class is not already available locally and the java.rmi.server.codebase property has been set properly to specify where the class files are located on the server.


I'm no RMI expert, but my basic understanding of this is that if you start the RMI Registry up in the folder that contains the classes, then you aren't actually testing that the classes are being dynamically loaded - because they aren't being dynamically loaded, because the RMI Registry has access to the classes directly.

I'm only starting to read up on RMI. So don't take my word for it! Maybe someone else on here can confirm\clarify.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5545
    
  13

Just use the createRegistry method from LocateRegistry to start the rmi registry.

If you want to check if dynamic class downloading does not occur, you can find here a bit of inspiration.
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Sean Keane wrote:I'm no RMI expert, but my basic understanding of this is that if you start the RMI Registry up in the folder that contains the classes, then you aren't actually testing that the classes are being dynamically loaded - because they aren't being dynamically loaded, because the RMI Registry has access to the classes directly.


I'm just reading this again and it may be misleading! After some more reading on RMI and the use of RMI in the assignment I think I've a better understanding now. Just to clear up my previous post as it may seem misleading in the context of this assignment.

If you want your classes to be dynamically loaded then you shouldn't start the RMI registry in a manner that it has access to the class files that are meant to be dynamically loaded - for the reasons outlined in the article I referenced in my previous post.

But this is not a concern for the assignment as one of the requirements for the assignment is that dynamic loading is not used.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Restrictions on RMI - what does that mean to me?