• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with already running RMIRegistry

 
Alan Morgan
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11866
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Alan Morgan
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11866
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic