title: Spring, thread and warnings at app termination time
body: <p>I'm building a web app with j2ee, hibernate and Spring. At a certain point the app has to send a number of emails, so I thought of putting this task in a separate thread. Details:</p>
  
  <ul>
  <li>There is syncronization on a number of status variables the thread and the controller share</li>
  <li>There is NOT synchronization on the service bean that is shared with the controller (should it be?).</li>
  </ul>
  
  <p>Anyway, when I shut down the app, I receive the following <em>worrying</em> message:</p>
  
  <pre><code>...
  INFO: Closing Hibernate SessionFactory
  25-mar-2011 10.02.14 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
  GRAVE: The web application [/Tomcat6Locale] registered the JDBC driver [org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
  25-mar-2011 10.02.14 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
  GRAVE: The web application [/Tomcat6Locale] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
  25-mar-2011 10.02.14 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  GRAVE: The web application [/Tomcat6Locale] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
  25-mar-2011 10.02.15 org.apache.coyote.http11.Http11Protocol destroy
  INFO: Stopping Coyote HTTP/1.1 on http-8080
  </code></pre>
  
  <p>That I was not getting before the thread trick... In the end when one of these threads completes, they just return. I don't do anything special. Should I do more?</p>