title: tomcat + spring + quartz = shutdown error
body: <p>We are trying to do what appears to be a very straightforward thing, but it is not working, and solutions I find online seem to complex for something so basic, so I feel like I should ask again.
  We have a Spring web application running under tomcat.  We added Quartz scheduler to it:</p>
  
  <pre><code>&lt;bean id="myScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt;
        &lt;property name="dataSource" ref="myDataSource"/&gt;
        &lt;property name="transactionManager" ref="myTransactionManager"/&gt;
  
        &lt;property name="overwriteExistingJobs" value="true"/&gt;
  
        &lt;property name="autoStartup" value="true"/&gt;
  
        &lt;property name="jobFactory"&gt;
           &lt;bean class="AutowiringSpringBeanJobFactory"/&gt;
        &lt;/property&gt;
  
        &lt;!-- NOTE: Must add both the jobDetail and trigger to the scheduler! --&gt;
        &lt;property name="jobDetails"&gt;
           &lt;list&gt;
              &lt;ref bean="jobDetailAutoSendPublishedReport" /&gt;
           &lt;/list&gt;
        &lt;/property&gt;
        &lt;property name="triggers"&gt;
           &lt;list&gt;
              &lt;ref bean="cronTriggerAutoSendPublishedReport"/&gt;
           &lt;/list&gt;
        &lt;/property&gt;
  
        &lt;property name="quartzProperties"&gt;
           &lt;props&gt;
              &lt;!-- Main Scheduler Properties For A Clustered Scheduler --&gt;
              &lt;prop key="org.quartz.scheduler.instanceName"&gt;test&lt;/prop&gt;
              &lt;prop key="org.quartz.scheduler.instanceId"&gt;AUTO&lt;/prop&gt;
              &lt;prop key="org.quartz.scheduler.skipUpdateCheck"&gt;true&lt;/prop&gt;
              &lt;prop key="org.quartz.scheduler.idleWaitTime"&gt;60000&lt;/prop&gt;
  
              &lt;!-- ThreadPool --&gt;
              &lt;prop key="org.quartz.threadPool.class"&gt;org.quartz.simpl.SimpleThreadPool&lt;/prop&gt;
              &lt;prop key="org.quartz.threadPool.threadCount"&gt;5&lt;/prop&gt;
  
              &lt;!-- Shutdown Hook Plugin --&gt;
              &lt;!--prop key="org.quartz.plugin.shutdownhook.class"&gt;org.quartz.plugins.management.ShutdownHookPlugin&lt;/prop&gt;
              &lt;prop key="org.quartz.plugin.shutdownhook.cleanShutdown"&gt;true&lt;/prop--&gt;
  
              &lt;!-- JDBC JobStore --&gt;
              &lt;prop key="org.quartz.jobStore.class"&gt;org.quartz.impl.jdbcjobstore.JobStoreTX&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.driverDelegateClass"&gt;org.quartz.impl.jdbcjobstore.oracle.OracleDelegate&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.useProperties"&gt;false&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.isClustered"&gt;true&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.clusterCheckinInterval"&gt;300000&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.misfireThreshold"&gt;300000&lt;/prop&gt;
           &lt;/props&gt;
        &lt;/property&gt;
     &lt;/bean&gt;
  </code></pre>
  
  <p>And then when I try to shutdown tomcat I get the following error and tomcat fials to shutdown:</p>
  
  <p>appears to have started a thread named [DefaultQuartzScheduler_QuartzSchedulerThread] but has failed to stop it. This is very likely to create a memory leak.
  Jan 27, 2015 1:09:35 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks</p>
  
  <p>My fix is to add the following to web.xml:</p>
  
  <pre><code> &lt;!-- Start Quartz --&gt;
     &lt;listener&gt;
        &lt;listener-class&gt;
           org.quartz.ee.servlet.QuartzInitializerListener
        &lt;/listener-class&gt;
     &lt;/listener&gt;
     &lt;context-param&gt;
        &lt;param-name&gt;quartz:shutdown-on-unload&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
     &lt;/context-param&gt;
     &lt;context-param&gt;
        &lt;param-name&gt;quartz:wait-on-shutdown&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
     &lt;/context-param&gt;
     &lt;context-param&gt;
        &lt;param-name&gt;quartz:start-on-load&lt;/param-name&gt;
        &lt;param-value&gt;false&lt;/param-value&gt; &lt;!-- let spring handle starting --&gt;
     &lt;/context-param&gt;
     &lt;!-- End of Quartz --&gt;
  </code></pre>