RMI Registry leaves thread running

I've searched the postings about this topic and none of them have been helpful. I create an RMI registry at port 1099 in my app, use it, and then try to shut it down, but it leaves a thread running.

The following sample code shows what my code does (in a condensed form):

Registry registry = LocateRegistry.createRegistry(1099);

Communicator c =new CommunicatorImpl();

registry.rebind("//localhost/remoteserver", c );

Naming.rebind("rmi://localhost:1099/TriggerService", c);

registry.unbind("//localhost/remoteserver");

Naming.unbind("rmi://localhost:1099/TriggerService");

boolean b = UnicastRemoteObject.unexportObject(registry,true);

System.err.println("unexported: "+b );

When I run this code in Eclipse and the code exits, I still have a process running that was spawned by "LocateRegistry.createRegistry(1099)", but I can't figure out how to get a handle for it within my program, so that I can kill it. I've read that it will end when the JVM ends, but the RMI portion of my app is only a small part and I need the rest of it to keep running. Is there a way to stop this thread?

Thanks,

Tony

[1409 byte] By [a_childsa] at [2007-11-26 15:10:04]
# 1
It's a long-standing bug. Applies not just to the RMI Registry but to any server port allocated by RMI.
ejpa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...
# 2
Has it been fixed in 1.6? Are there any work-arounds?
a_childsa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...
# 3
Yes: http://java.sun.com/javase/6/docs/technotes/guides/rmi/relnotes.html.No workaround that I can think of.
ejpa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...
# 4
1.6 does not solve my problem. It still leaves a thread running.
a_childsa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...
# 5

I may have mis-spoke. I think that 1.6 leaves a process running, not a thread. In previous versions of Java, I see a separate thread running in the Eclipse debugger, but with 1.6 I see that javaw.exe continues to run (separate from the eclipse javaw.exe). Is that another virtual machine? If so, that's even worse than having a rogue thread. Can anyone comment on this and why RMI does not allow us to start and stop the service at will? Or maybe there's a better API that is meant for the type of intermittent transmissions I'm doing? Thanks.

a_childsa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...
# 6

Well I only see 'createRegistry' and 'getRegistry' I don't see any 'destroyRegistry' methods. So I don't know.

What I used to do back in the day was to use Runtime to start an external process for processes that I needed to kill later on. So perhaps you can use the runtime to start the registry from the command line so to speak. Then hold a reference to the returned process. Then you can kill that process when you want the registry to die. In this case you will for sure be creating a new 'jvm' for the registry to run within. (if the registry is a java program)

Otherwise I have no idea why you would be seeing an extra java process. If you run the eclipse debugger, the debugger should not exit until the whole process is done. Even when the program is done, the debugger will still be 'live' and you can push the stop button to stop the whole launched process.

_dnoyeBa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...
# 7
Thanks. I'll give that a try. I'll have a look when I get to my work machine to see what the extra javaw.exe is.
a_childsa at 2007-7-8 9:00:48 > top of Java-index,Core,Core APIs...