5 Replies Latest reply on Jun 6, 2012 3:01 AM by galder.zamarreno

    how to use shutdownHookBehavior

    dex80526

      There is 3 options for shutdownHookBehavior (default, register, dont_register). which one I should use? or what are the differences of those options?

       

      I need to properly shutdown H2 db when I stop the application. I saw a lot of the following SEVER logs in catalina.out when I stop the application:

       

      SEVERE: The web application [] appears to have started a thread named [H2 File Lock Watchdog /test/data/user_10.200.22.22/UserProfile.lock.db] but has failed to stop it. This is very likely to create a memory leak.

        • 1. Re: how to use shutdownHookBehavior
          dex80526

          No response yet. I'll extend the question a bit. How do I hookup a customerized shutdown hooker?  For example, I may want to call some DB shutdown code in the hooker.

          • 2. Re: how to use shutdownHookBehavior
            mgencur

            You cannot add your own shutdown hook to infinispan. You can just change the behavior regarding when the the default shutdown hook is registered. The default implementation can be found at GlobalComponentRegistry.java.

            • 3. Re: how to use shutdownHookBehavior
              galder.zamarreno

              From the ShutdownHookBehavior enum javadoc:

               

                 /**

                  * By default a shutdown hook is registered if no MBean server (apart from the JDK default) is detected.

                  */

                 DEFAULT,

                 /**

                  * Forces the cache to register a shutdown hook even if an MBean server is detected.

                  */

                 REGISTER,

                 /**

                  * Forces the cache NOT to register a shutdown hook, even if no MBean server is detected.

                  */

                 DONT_REGISTER

               

              The idea here is that if a JVM is shutdown, whether the Infinsipan resources should be cleared or not. In a managed environment, such as an AS, it has its own shutdown hook that will guarantee that all services are shutdown, so normally there's no need for one. In standalone apps, it's usual to see a shutdown hook to shut all daemon threads...etc.

              • 4. Re: how to use shutdownHookBehavior
                dex80526

                Thanks for all the responses.

                 

                My real issue is that TOMCAT complains some processes (threads related to JDBC cache loader) are not removed when the application stops. I'll try some other approaches.

                • 5. Re: how to use shutdownHookBehavior
                  galder.zamarreno

                  Right, the best is for your app to shutdown the cache manager when it undeploys or stops, if that's somehow possible. Alternatively, you could also try REGISTER as shutdown hook and see if that works.