title: Spring beans destroyed , but quartz performing cleanup and requires dataSource for connection and throwing up exception
body: <p>While shutting down tomcat, I see that spring managed beans get destroyed, among which is dataSource. Spring instructs quartz to shutdown, and Quartz is running with config waitForJobsToCompleteOnShutdown = true.  So, when finishing up jobs, I am getting below expection with quartz as there is no dataSource for it to get a connection:</p>
  
  <pre><code>2013-06-24 17:22:47,952 ERROR | schedulerFactoryBean_Worker-1 | org.quartz.core.ErrorLogger  | An error occured while marking executed job complete. job= 'DEFAULT.invoiceResponseJobDetail' 
      org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'springNonTxDataSource.schedulerFactoryBean': java.lang.NullPointerException
      at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:173) ~[quartz-2.1.7.jar:na]
      at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3788) ~[quartz-2.1.7.jar:na]
      at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3760) ~[quartz-2.1.7.jar:na]
      at org.quartz.impl.jdbcjobstore.JobStoreSupport.triggeredJobComplete(JobStoreSupport.java:3000) ~[quartz-2.1.7.jar:na]
      at org.quartz.core.QuartzScheduler.notifyJobStoreJobComplete(QuartzScheduler.java:1753) ~[quartz-2.1.7.jar:na]
      at org.quartz.core.JobRunShell.run(JobRunShell.java:281) ~[quartz-2.1.7.jar:na]
      at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) ~[quartz-2.1.7.jar:na]
      Caused by: java.lang.NullPointerException: null
      at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:165) ~[quartz-2.1.7.jar:na]
      ... 6 common frames omitted
  </code></pre>
  
  <p>DataSource config:</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="java:comp/env/jdbc/springDataSource" /&gt;
      &lt;property name="lookupOnStartup" value="true" /&gt;
      &lt;property name="proxyInterface" value="javax.sql.DataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Spring quartz config:</p>
  
  <pre><code>&lt;bean id="schedulerFactoryBean"
      class="org.springframework.scheduling.quartz.SchedulerFactoryBean" depends-on="dataSource"&gt;
  
      &lt;property name="waitForJobsToCompleteOnShutdown"&gt;
          &lt;value&gt;true&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property name="triggers"&gt;
          &lt;list&gt;
              &lt;ref bean="accountRequestJobDetailTrigger" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  
      &lt;property name="schedulerContextAsMap"&gt;
          &lt;map&gt;
              &lt;entry key="accountRequestJob" value-ref="accountRequestJob" /&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  
      &lt;property name="quartzProperties"&gt;
          &lt;props&gt;
              &lt;prop key="org.quartz.scheduler.skipUpdateCheck"&gt;true&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.class"&gt;org.quartz.impl.jdbcjobstore.JobStoreCMT&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.driverDelegateClass"&gt;org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
              &lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.tablePrefix"&gt;QRTZ_&lt;/prop&gt;
              &lt;prop key="org.quartz.jobStore.isClustered"&gt;true&lt;/prop&gt;
              &lt;prop key="org.quartz.scheduler.instanceName"&gt;SAPClusteredScheduler&lt;/prop&gt;
              &lt;prop key="org.quartz.scheduler.instanceId"&gt;AUTO&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>How, can I let this clean up of jobs happen before spring beans are destroyed?</p>