Announcement Announcement Module
No announcement yet.
java process won't stop? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • java process won't stop?

    I've just integrated sprint integration into a local java app... I have all the beans pulled into a separate xml file. If I include that xml in springs startup, the java process never stops. If I remove that file, it ends normally. I took a thread dump and noticed there were quite a few activemq and jms threads still running (although, interestingly, the main thread was done.)

    Any ideas? Do I need to configure anything to shutdown cleanly?


    ps - this is the thread I'm concerned about.

    "org.springframework.jms.listener.DefaultMessageListenerContainer#0-1" prio=6 tid=0x39a32400 nid=0x12a4 waiting on condition [0x3b08f000..0x3b08fd14]
       java.lang.Thread.State: TIMED_WAITING (sleeping)
    	at java.lang.Thread.sleep(Native Method)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.sleepInbetweenRecoveryAttempts(
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$
    	- locked <0x09667718> (a java.lang.Object)
       Locked ownable synchronizers:
    	- None

  • #2
    Those processes run in their own threads (not main) and intentionally keep running in the background. Everything should shutdown gracefully if you call context.close() or context.stop() on the ApplicationContext itself. You can also register a shutdown hook.


    • #3
      I added a finally clause to the main method of each of my applications to close the context... that seemed to do the trick. I really liked the idea of the shutdown hook, since I had multiple applications to fix, but that didn't work. The shutdown hook never got called. (Possibly because the messaging thread is not a daemon thread, and the shutdown hook only gets called when all the non-daemon threads stop.)

      anyway, thanks for the help. I think I'm all set now.