Two Laptop Bag*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes codebase and classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "codebase and classpath" Watch "codebase and classpath" New topic
Author

codebase and classpath

Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171
Hi all. . .
I have tried 55 ways from Sunday to use the codebase property on my server startup, but I can't ever get it to work. I keep getting the stupid UnMarshall and ClassNotFound exceptions, because rmiregistry doesn't know where to find my stub class. My command line looks like this:
java -Djava.rmi.server.codebase=file://c:\pathname\server.jar suncertify.server.FBNServer
It never works and I have tried multiple variations of the format (I'm assuming that the server and rmiregistry will be running on the same machine).
The only other solution I have is to set the CLASSPATH to my jar files before starting rmiregistry.
I'd really like to figure out the codebase problem, but as I have an alternate solution, I'm running out of patience, as everything else for the project is completely tested and ready for upload.
Any quick ideas on how to fix the codebase problem or should I just use the other solution?


Regards,
Jim
SCJP, SCJD, SCWCD, SCEA Part I
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Jim,
Forget about codebase and CLASSPATH and don't require that the registry be started before starting the server. You can start the registry from your server with LocateRegistry.createRegistry(port).
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171
Originally posted by Michael Morris:
Hi Jim,
Forget about codebase and CLASSPATH and don't require that the registry be started before starting the server. You can start the registry from your server with LocateRegistry.createRegistry(port).
Hope this helps,
Michael Morris


Michael,
Thanks!
I'll try this and see if I can get it to work. Just one question: If I start rmiregistry from the server, does it use the CLASSPATH variable that was set for the server program? Is that how it knows where to find the stub class?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Jim,
Absolutely. Put the *&%$# CLASSPATH out of your mind. The sandbox and the CLASSPATH: bane of all Java Developers

Michael Morris
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

The sandbox and the CLASSPATH: bane of all Java Developers

ROFL
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
not to beat a dead classpath...
but it was my understanding that if the registry had access to stubs via the classpath, it was a bad thing. The registry could only download code if it had access via the codebase.
I'm curious: does using somehow interpret the classpath for the server into a codebase under the covers?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Eric,

... somehow interpret the classpath for the server into a codebase under the covers?

I don't know for sure. You may need to direct this question to the Distributed Java forum where there are those who understand the more esoteric features of RMI. There is nothing in the javadocs that indicates the mechanisms that LocateRegistry uses to locate classes. But if there is no codebase set then isn't the codebase . (the user directory)? If that's the case then I suppose that the answer is yes.
Michael Morris
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
For this assignment, you cannot use java.rmi.codebase property because you are not going to have a web server or refer using file URL. So you are going to make the _Stub files visible to both client and RMI Registry. So there are two ways for the RMI Registry to get your _Stub files.
1) You can either start the RMI Registry in a seperate console window and set the CLASSPATH env value before starting the registry
2) Use LocateRegistry and RMI Registry can find the _Stub using the CLASSPATH for the server startup.
When no codebase is used, the remote object is marshalled and annotated with null for the codebase from the RMI Server to the RMI Reigstry. Also this applies to the marshalling from RMI Registry to the client. Hope that helps.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Thanks for the explanation Sai.
Michael Morris
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Use LocateRegistry and RMI Registry can find the _Stub using the CLASSPATH for the server startup

Seems like this is a better choice for the assignment because it will result in fewer steps that the evaluator would have to take to get your assignment up and running.
Guess you could use codebase and a file URL, but that would require your having tedious instructions in your readme in order to have the evaluator specify the correct location.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

"And I told Dom too because they�ve moved my desk four times. I used to be by the window, where I could see the squirrels and they were merry..."

I am just curious, what makes this quote so spectacular that you decided to use it as your signature? By this standard, every one of my posts here (well, almost every one) should be engraved some place.
Eugene.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
It's a quote from Milton in Office Space. You probably knew that.
I chose it to add a less-serious tone to things I say. Not that any other signature here is too serious, there are some very insightful ones out there. Some very funny ones too.
My actual favorite quote is
True nobility and strength comes not from being superior to other people, but from being superior to your former self.

A Zen teaching. I'm not a Zen master by any stretch and thought that a quote like this may be heavy-handed if given as a signature.
Thoughts? Got a kick out of your engraving idea.
e
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Actually Eugene, there are a number of your posts that I've saved to my "Ranch" folder of reference material to use while working on the SCJD.
So, in a sense, your posts have been engraved somewhere.
[ August 16, 2002: Message edited by: Erick Reid ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: codebase and classpath
 
Similar Threads
RMI Explanation
ClassNotFoundException when binding
Issue with a Java RMI application not working on other machines
HELP: Muilt-Threaded Server
I am getting ClassNotFoundException for stub file