This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Problem with already running RMIRegistry 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 "Problem with already running RMIRegistry" Watch "Problem with already running RMIRegistry" New topic
Author

Problem with already running RMIRegistry

Alan Morgan
Ranch Hand

Joined: Apr 18, 2005
Posts: 113
Hi,

I have a RegisterDatabase class which starts an rmiregistry and binds my Data object to it.

If there is one running then I catch the exception and do getRegistry instead of a createRegistry.

Then I bind the object to the retrieved registry.

However when I try this I am getting the following exception:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: suncertify.remote.RemoteDBImpl_Stub


Not really sure how to solve this as the RemoteDBImpl_Stub does exist.

Any ideas ?

Thanks.
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Alan, add a static boolean to RegisterDatabase that tells you whether or not the registry has been created.

Now if only all things in life were that simple
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Alan,

The simplest way to handle this is to write in your design decision document that running with an externally started RMI Registry is possible, but it has not be detailed since doing so would contradict the instruction requirements .

Background information: The situation is that the rmiregistry needs to be able to find the stubs just in case a client requests them. So you have a choice - you can start the rmiregistry in the directory that contains your stub classes (or the start of the package directories that will allow it to find the stub classes), or start the registry with the command line option that allows you to specify the classpath for the stub classes.

That was a quick and dirty explanation since it is not really needed for the assignment - however it is something that you might need to know if you are creating RMI services in your real job. So if it is not making sense and you would like to know more, just say so. (I also think that Sun's RMI tutorial describes this - but it has been a long long time since I looked at it).

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Alan Morgan
Ranch Hand

Joined: Apr 18, 2005
Posts: 113
Originally posted by Andrew Monkhouse:
The simplest way to handle this is to write in your design decision document that running with an externally started RMI Registry is possible, but it has not be detailed since doing so would contradict the instruction requirements .



Hi Andrew,

Thanks for the reply.

So I should leave the code in there that would allow connection to an already running registry ?

Or just code for running with registry I started myself and document as you indicated.

How exactly would "doing so would contradict the instruction requirements" ?

Thanks again,

Alan.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Alan
How exactly would "doing so would contradict the instruction requirements" ?
Heh - I am probably being too conservative with my reading of the instructions (deliberately ). But given the restrictions on how you must start the server (no command line arguments other than "server", no manual editing of files, ...) I think that starting a separate process is going against the spirit of the instructions.

Regards, Andrew
 
jQuery in Action, 2nd edition
 
subject: Problem with already running RMIRegistry
 
Similar Threads
RMI error: java.rmi.UnmarshalException: error unmarshalling arguments
Starting the RMI server on Windows
RMI - NoClassFoundException
RMI AccessException problem
Is it possible to register multiple nonlocal remoteobjects with rmiregistry ?