File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI Explanation 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 "RMI Explanation" Watch "RMI Explanation" New topic
Author

RMI Explanation

Joe Murray
Greenhorn

Joined: Sep 19, 2001
Posts: 9
Here's my situation:
I set the classpath on my server to nothing. Here is my server command line:
java -Djava.security.policy=file:///c:\server\db.policy -Djava.rmi.server.codebase=file:/server.jar -jar server.jar C:\Project\db.db
I had the drive letter c:\ in the codebase but I read somewhere that a drive letter is a badly formed url, so I took it out. Whatever. Didn't help.
My main method in the server bundle contains these lines:
System.setSecurityManager(new RMISecurityManager());
LocateRegistry.createRegistry(1099); // loads the rmiregistry
FBNServer._rmiServ = new RMIServerImplementation(dbname); //static implementation of the interface
Naming.rebind("/FBNServer", _rmiServ );

On the client machine, I set the classpath to nothing (or client.jar, same results). The command line looks like this:
java -Djava.security.policy=file:///c:\client\db.policy -Djava.rmi.server.codebase=rmi://ipadd/FBNServer/ -jar client.jar -remote ipaddress
The naming lookup line looks like this:
_rmiInterface = (RMIInterface)Naming.lookup("rmi://ip/FBNServer");
I'm still getting the Stub class not found error.
What I've tried:
- running the rmiregistry separately with no classpath and with the classpath to the server.jar.
- running the extracted jars with and without classpaths set.
- setting the codebase of the client to the server.jar, to the url: rmi://ipadd/FBNServer/, and also not having a codebase.
- rmic-ing the Stub file with a classpath set to the server.jar, to the extracted classes directory, and with no classpath set.
The only thing that does work is if the client and server are running on the same machine. Rather useless for a distributed application
Does the Stub have to be in the client bundle in order for the program to work? If so, what the is the point of RMI if after every change to the server you have to build a new client and redistribute it. If not, why doesn't the stub get picked up by my client?


BSCS<br />SCJP, SCJD
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Joe Murray:
Does the Stub have to be in the client bundle in order for the program to work? If so, what the is the point of RMI if after every change to the server you have to build a new client and redistribute it. If not, why doesn't the stub get picked up by my client?

Yep; you can automatically download stubs but for the purpose of the FBN application I wouldn't go there. The point of RMI is the level of transparency it gives you in developing distributed applications; it will not handle distribution and updating for you. If you're interested in things like that, check out Java WebStart.
- Peter
 
Consider Paul's rocket mass heater.
 
subject: RMI Explanation