Menu

#161 Client shutdown problem

v0.7.7-alpha-3
open
client (26)
5
2007-04-25
2007-03-28
No

We have an OpenJMS-Client integrated in a web application. The OpenJMS connection is created and closed in an own JMSManager class which is started and stopped in a ServletContextListener. When starting the ServletContext we perform:

// initialize JNDI-Context
context = new InitialContext(cxtEnv);
// get connection
topicConnection = ((TopicConnectionFactory) context.lookup(factoryKeyTopic)).createTopicConnection();
topicConnection.start();
// create a QueueSession
topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

on shutdown we do:

topicSession.close();
topicConnection.close();
context.close();

If the servlet container (Tomcat 5.5) is shut down the ClockDaemon from DefaultConnectionPool stays alive. After some seconds a NullPointerException is thrown. The tomcat process never stops. The following Stacktrace is logged:

Exception in thread "ManagedConnectionReaper1" java.lang.NullPointerException
at org.apache.log4j.LogManager.getLogger(LogManager.java:188)
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
at org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:193)
at org.exolab.jms.net.connector.DefaultConnectionPool$IdleReaper.run(DefaultConnectionPool.java:644)
at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Log4J may not be available after the ServletContext is shutdown.

The following threads keep running:

org.apache.catalina.startup.Bootstrap at localhost:2738
Thread [Clock Daemon] (Running)
Thread [Timer-1] (Running)
Thread [http-8080-Processor25] (Running)
Thread [TP-Processor4] (Running)
Thread [DestroyJavaVM] (Running)

Discussion

  • Tim Anderson

    Tim Anderson - 2007-04-03

    Logged In: YES
    user_id=557161
    Originator: NO

    Have you tried 0.7.7-beta-1?

     
  • Jan Dittberner

    Jan Dittberner - 2007-04-11

    Logged In: YES
    user_id=32700
    Originator: YES

    I tried 0.7.7-beta-1 and the problem still occurs.

     
  • Tim Anderson

    Tim Anderson - 2007-04-25

    Logged In: YES
    user_id=557161
    Originator: NO

    When the last reference to the physical connection to the server is released, a reaper thread will be started to reap the connection.
    This starts approximately 5 seconds after the reference is released and closes the connection if it hasn't been subsequently used.

    You may be able to work round the NullPointerException by adding a sleep in the ServletContextListener to try and ensure that tomcat doesn't unload resources until the DefaultConnectionPool has completed reaping.

    Also note that of the above threads, only [Clock Daemon] belongs to OpenJMS, and is a daemon thread - it won't prevent tomcat shutting down.

     
  • Tim Anderson

    Tim Anderson - 2007-04-25
    • assigned_to: jalateras --> tanderson
     

Log in to post a comment.