• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

rmi registry

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a question concerning rmiregistry. Is it safe to assume that when we are operating in network mode, the rmiregistry is already started (by using the command 'start rmiregistry' on the server), or do we somehow have to start the rmiregistry programaticly when we are starting the program with the 'server' command line argument (the part where we have to specify the server and database settings). If we are required to start the rmiregistry in our program, how is this done? Or am I completely seeing things wrong? What actions do we need to perform when starting the program in "server" mode?

with kind regards,
Bert Gossey
 
bert gossey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or isn't it necessary to start the server on the client side. In other words, when using the program in network mode, first go to the server and run the program with the command-line argument "server" indicating on which port the rmiserver should listen. After that you can run the program on a client indicating that you just want to run the client?

Bert
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you start it programmatically on the server side.
When you start in client mode, you'll have to assume your server is already rumnning and has already registered itself. Starting the registry on the client side would do you no good - either the server is up, in which case the registry is already running, or it is not up, in which case a running registry would be useless to you.

It works something along these lines:


will start the registry. If it's already running, use

instead.

Next, bind your service to the registry like this:


On the client side, do something like this:


finds the registry. And then,

gets you a reference to your remote object.

Hope that helps.
 
bert gossey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this helps a lot,... going to try it out now.

thanks,
Bert
 
bert gossey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just, one quick question: is there a way to know if the registry is already running?

with kind regards,
Bert
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the client use the following API. This returns a stub (remote reference) to the remote registry. If this call fails then it will throw java.rmi.RemoteException. And you will know that there is problem. What you **cannot** rely after trapping this exception

1. You cannot be sure whether the root cause is the network problem OR the registry outage
2. Regitry may be running fine. But exception might have been thrown due to some problem on the way back.

API:
java.rmi.registry.LocateRegistry.getRegistry(String host, int portNum)

Cheers
[ June 23, 2006: Message edited by: Nishant Verma ]
 
bert gossey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to stop the rmiregistry to run?

Bert
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, it terminates when the JVM it runs in terminates (so when your server stops).
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have tried to programmatically find out if the rmi server is already started on a port using the following line

Executing the line throws no exception and the registry object is not null even if no rmiregistry runs at the specified port. But when I try to call some methods on the Registry bject, like list(), an exception is thrown. I can use this additional "method calling" as a workaround to jump to the conclusion that the rmi registry does not run at the specified port but I do not find the solution very clean.
Does somebody has another ideea ?
Thanks,
Liviu
 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the RMI registry running or not i have reached the following conclusion.
If the RMI registry is started programatically,it will be run until the program that ran that registry ends.

Here is what i tried

Executing the first program :
java.rmi.registry.LocateRegistry.createRegistry(4334);
The program executes and finished

In the other program :
java.rmi.registry.LocateRegistry.getRegistry().list();
An exception is thrown at Runtime

For what is proposed.I dont see anything in try to call any of the methods on the registry object to know if it is running or not.I cant see other way.
[ October 13, 2006: Message edited by: Khaled Mahmoud ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic