6 Replies Latest reply on Jan 20, 2012 12:58 PM by cbrock

    SOLVED: Service lifecycle

    david.grigglestone

      In the doc I see that session lifecycles are bound to the underlying HTTP session, however it is not apparent what the lifecycle of a service is.

       

      In particular I am trying to understand the correct way(s) to cleanup any threads that might be created by the service. It is not obvious to me how to get a callback when the service should be destroyed.

       

      I'd also like to understand why I see messages from the web-container (in my case Tomcat) like those below when I undeploy an example app like the stockdemo?

       

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Thread-6] but has failed to stop it. This is very likely to create a memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Dispatch Worker Thread] but has failed to stop it. This is very likely to create a memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Dispatch Worker Thread] but has failed to stop it. This is very likely to create a memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Thread-7] but has failed to stop it. This is very likely to create a memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [ExecutorPoolWorker] but has failed to stop it. This is very likely to create a memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: The web application [/errai-bus-demos-stockdemo] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@1a5a58e0]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@2180e7a4]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

      SEVERE: The web application [/errai-bus-demos-stockdemo] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@15e7d12b]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@26556949]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

      SEVERE: The web application [/errai-bus-demos-stockdemo] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@31734b48]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@8537d55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

      SEVERE: The web application [/errai-bus-demos-stockdemo] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@21495bb8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@57249e1a]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

      Jan 18, 2012 1:03:23 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

      SEVERE: The web application [/errai-bus-demos-stockdemo] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com.google.inject.internal.InjectorImpl$1@2507e9a8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@2a7d2796]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

        • 1. Re: Service lifecycle
          cbrock

          For the purpose of servlet-based Errai applications, the Errai service lifecycle is tied to the HttpSesison lifecycle and dies with it.

          • 2. Re: Service lifecycle
            david.grigglestone

            So two aspects:

            1. I need to find out how to get the HttpSession and tap into its lifecycle from my service .. sorry to be a dummy here!
            2. Are the "SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Dispatch Worker Thread] but has failed to stop it. This is very likely to create a memory leak." type messages a result of a bug in Errai .. i.e. shouldn't it clean up the threads it has created?
            • 3. Re: Service lifecycle
              cbrock

              This has been fixed and should show up in our next SNAPSHOT in the next few hours.

              • 4. Re: Service lifecycle
                david.grigglestone

                Thanks for quick fixes .. too bad .. looks like snapshot build are failing?

                • 5. Re: Service lifecycle
                  david.grigglestone

                  fyi Mike .. I built and tried the latest 2.0, but still see the following when I shutdown Tomcat:

                   

                  INFO [WorkerFactory] stopping workering pool.

                  Jan 19, 2012 10:45:43 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

                  SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.

                  Jan 19, 2012 10:45:43 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

                  SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Dispatch Worker Thread] but has failed to stop it. This is very likely to create a memory leak.

                  Jan 19, 2012 10:45:43 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

                  SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Dispatch Worker Thread] but has failed to stop it. This is very likely to create a memory leak.

                  Jan 19, 2012 10:45:43 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

                  SEVERE: The web application [/errai-bus-demos-stockdemo] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak.

                  • 6. Re: Service lifecycle
                    cbrock

                    I believe these warnings can safely be ignored. It appears this is just a case of the asynchronous shutdown of the errai worker pools racing against Tomcat's check. Which is to say, the threads do get shutdown, but moments after Tomcat displays this warning.