Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Reaper Thread

 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a Java application that uses Spring for its RMI needs. I tried to lookup a bean, and it didn't exist, so the application crashed as expected. However, the application hung indefinitely because of the non-daemon thread "RMI Reaper" that was running. Does anyone know what this thread is and why it would hang like this?

Thanks,
Jeff
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say the application crashed, what is it you mean?
You got a Null pointer?
If so, then this means that the request thread died and not the JVM crashed.
RMI creates keep alive threads to keep the VM alive till the point there are no remote objects existing in the JVM.
RMI keeps a count of the number of remote objects exported via RMI.
RMI reaper polls the reference queue for the objects that were exported and hence when these objects are garbage collected, the RMI reaper removes them from its object table and mark it for removal.
RMI reaper keeps the VM alive till the time there are any non-permanent RMI objects alive in the JVM.
Also, this does not mean that the RMI reaper thread is hung, it is just doing its job i.e. waiting for the exported objects to be GCed.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that info. By crashed, I mean that I got a Spring exception saying that the bean does not exist. I guess maybe in the "finally" block that launches my application I need to clean up all the beans or something like that (they all cleanup under normal run circumstances).
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.exit() is the only way to end an RMI Server. There are other threads active in the RMI Runtime as well.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edward Harned:
System.exit() is the only way to end an RMI Server.


Really? Yuk.

CORBA doesn't have that problem - well, not the home-made ORB that we have, anyway. Strange that RMI should be less friendly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic