aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Start and Stop RMI Server 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 "Start and Stop RMI Server" Watch "Start and Stop RMI Server" New topic
Author

Start and Stop RMI Server

Akash Singh
Ranch Hand

Joined: Aug 21, 2003
Posts: 80
I have a user interface, that takes port no and dbfile file name . I have buttons to start and stop server. Starting and stoping once is fine, but if i try to restart after stopping, i get message objId is already in use.
To stop my server , user interface exits the JVM, and this stops the server.
I feel , this is not nice way. I should be able to stop the server, while GUI is displayed and restart it again.
code to start and stop server.


Regards,
Akash
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11279
    
  59

Hi Akash,
Your problem is because you cannot stop the Sun RMI Registry programattically.
You can stop (or unbind) your server process from the registry, and then bind a new server process to the registry.
You could even start a new registry on a new port (while still leaving the old registry running on the old port).
I would suggest that you either
  • catch the exception that tells you that the registry is already started, and log the message then try and continue with the bind process, or
  • don't allow the user to change the port after they have started the registry first time


  • Regards, Andrew


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

    Joined: Aug 21, 2003
    Posts: 80
    Thank You Very Much, Andrew.
    Werner Joerling
    Ranch Hand

    Joined: Mar 23, 2003
    Posts: 35
    Hello,
    to start and stop the server I use the following approach.

    And now I'm surprised:
    When I call stopServer(), the server stops to serve connections to new clients or clients, which want to reconnect. Ok, that's what I've expected.
    But clients, which got their connection before, are still working fine. (Until they try to reconnect).
    How can I achieve the connection created in startServer()
    stops to do its work? And why does it work at all?
    Thanks for all suggestions
    Werner
    [ November 14, 2003: Message edited by: Werner Joerling ]
     
    jQuery in Action, 2nd edition
     
    subject: Start and Stop RMI Server
     
    Similar Threads
    Rmi question
    RMI Question another one ?
    closing server
    NX: About RMI
    IS this Interface design OK