Announcement Announcement Module
No announcement yet.
RMI Registry is not shutdown Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RMI Registry is not shutdown

    I am having trouble with RMI shutdown.

    My application has several components which use RMI. Spring (1.1.5) starts up first and does LocateRegistry.createRegistry(). On shutdown RmiServiceExporter.destroy() does following:

    registry.unbind(this.serviceName); UnicastRemoteObject.unexportObject(this.exportedOb ject, true);

    However it does not do UnicastRemoteObject.unexportObject( Registry, true ). As a result my app does not shutdown and netstat shows that RMI is listening on its port.

    Possible solution:

    I am not sure if this is inline with design, but simple solution is to have RmiServiceExporter remember if it created registry, and remove it in destroy.

    Thank you.

  • #2
    More details on this issue:

    2 other components in the system do getRegistry()/createRegistry() sequence to export their services. On shutdown both do unexportObject(Remote,boolean) and unbind(String) if unexport did not fail. Both check if they created registry and if they did they attempt to unexport it.

    Startup sequence:

    1st component starts with Spring, which creates registry and exports object
    2nd component starts, gets registry etc
    3rd same

    Shutdown sequence:

    2nd & 3rd components unexport services they created and unbind them. Unexporting services that were created by Spring fails, evidently because they did not create them. Both attempt to unexport registry and both fail, because Spring services are still exported and bound.

    Spring successfully unexports and unbinds its service, but does not unexport registry. Thanks for any help.


    • #3
      Can someone please review and comment on this issue? I can contribute a fix for this as long as we discuss the design.

      My proposal is to introduce a registry life-cycle manager class, which will provide delegates for all registry calls from Spring components. After all components are unregistered it should attempt to remove registry if there are no other registration (i.e. registry.list().length == 0)

      Note that this issue may require different fixes for 1.5 and prior to 1.5. According to comments in this Java bug, 1.5 should allow creation of multiple registiries in the same VM.


      • #4
        FYI, we have already introduced an explicit RmiRegistryFactoryBean for Spring 1.2.3, providing the lookup/creation of an RMI Registry and also proper shutdown of a created Registry. This looks like an appropriate solution for your scenario.

        RmiServiceExporter has a corresponding "registry" property of type java.rmi.registry.Registry now, where you can pass in a reference to an RmiRegistryFactoryBean definition. RmiServiceExporter will not look up or create a registry in this case but rather simply use the given one.

        This will automatically lead to proper shutdown order: first all RmiServiceExporters, then the RmiRegistryFactoryBean that they all point to. This means that all services will be unexported first, then the registry itself.



        • #5

          Thanks a lot for you response. I hate to ask people questions that I could find out myself, but I looked at the documents online (assuming it would contain infromation for the latest release) and I did not see it there. How do I keep my self in the know on the new features? Thanks again.


          • #6
            Answering my own question.

            There are the change logs, however 1.2.3 is not released and there is no change log for it. I guess I hit that trouble at the same time as you did the change, so I could not find the answer myself.