title: Error occurred while unscheduling jobs
body: <p>When i shutdown JBOSS server <code>(ctrl+C)</code> results in the following exception</p>
  
  <pre><code>12:39:50,020 ERROR [com.kony.sync.console.job.scheduler.ConsoleJobScheduler] (ServerService Thread Pool -- 20) Error occurred while unscheduling jobs for application ID:PaaSJobs: org.qu
  artz.JobPersistenceException: Failed to obtain DB connection from data source 'syncQuartzDS': java.sql.SQLException: Could not retrieve datasource via JNDI url 'java:jboss/datasources/C
  onsoleDB' java.sql.SQLException: javax.resource.ResourceException: IJ000451: The connection manager is shutdown: java:jboss/datasources/ConsoleDB [See nested exception: java.sql.SQLExce
  ption: Could not retrieve datasource via JNDI url 'java:jboss/datasources/ConsoleDB' java.sql.SQLException: javax.resource.ResourceException: IJ000451: The connection manager is shutdow
  n: java:jboss/datasources/ConsoleDB]
          at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:715) [quartz-all-1.8.6.jar:]
          at org.quartz.impl.jdbcjobstore.JobStoreTX.getNonManagedTXConnection(JobStoreTX.java:69) [quartz-all-1.8.6.jar:]
          at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3785) [quartz-all-1.8.6.jar:]
          at org.quartz.impl.jdbcjobstore.JobStoreTX.executeInLock(JobStoreTX.java:90) [quartz-all-1.8.6.jar:]
          at org.quartz.impl.jdbcjobstore.JobStoreSupport.removeTrigger(JobStoreSupport.java:1458) [quartz-all-1.8.6.jar:]
          at org.quartz.core.QuartzScheduler.unscheduleJob(QuartzScheduler.java:965) [quartz-all-1.8.6.jar:]
          at org.quartz.impl.StdScheduler.unscheduleJob(StdScheduler.java:290) [quartz-all-1.8.6.jar:]
          at com.kony.sync.console.job.scheduler.ConsoleJobScheduler.unscheduleJob(ConsoleJobScheduler.java:225) [syncconsole.jar:]
          at com.kony.sync.services.context.SyncContextListener.contextDestroyed(SyncContextListener.java:221) [classes:]
          at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3427) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
          at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3920) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
          at org.jboss.as.web.deployment.WebDeploymentService.doStop(WebDeploymentService.java:171) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
          at org.jboss.as.web.deployment.WebDeploymentService.access$100(WebDeploymentService.java:60) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
          at org.jboss.as.web.deployment.WebDeploymentService$2.run(WebDeploymentService.java:113) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
          at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [rt.jar:1.6.0_26]
          at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) [rt.jar:1.6.0_26]
          at java.util.concurrent.FutureTask.run(Unknown Source) [rt.jar:1.6.0_26]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_26]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_26]
          at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_26]
          at org.jboss.threads.JBossThread.run(JBossThread.java:122)
  Caused by: java.sql.SQLException: Could not retrieve datasource via JNDI url 'java:jboss/datasources/ConsoleDB' java.sql.SQLException: javax.resource.ResourceException: IJ000451: The co
  nnection manager is shutdown: java:jboss/datasources/ConsoleDB
          at org.quartz.utils.JNDIConnectionProvider.getConnection(JNDIConnectionProvider.java:163) [quartz-all-1.8.6.jar:]
          at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:109) [quartz-all-1.8.6.jar:]
          at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:712) [quartz-all-1.8.6.jar:]
          ... 20 more
  
  Terminate batch job (Y/N)?
  </code></pre>
  
  <p>In the contextDestroyed(..)</p>
  
  <pre><code>            jobScheduler.unscheduleJob(PaaSConsoleUtil.PAAS_CLEANUP_JOB_NAME, PaaSConsoleUtil.JOB_GROUP);
  
          jobScheduler.shutdown(true);
          //scheduler.shutdown();
          executor.shutdown();   
  
          //clear the connection pool.
          ConnectionPool.clear();
          //Closing HttpClientIdleConnectionTimeoutThread through connector utils.
          ConnectorUtils.shutdown();
  
          //Shutdown the monitoring async executor task.
          SyncEventListenerUtil.shutdownThreadPool();
  
          //Destroy all console related threads here and deregister all drivers.
          ConsoleContextUtil consoleUtil = new ConsoleContextUtil(logger, false);
          consoleUtil.consoleContextDestroyed();
  </code></pre>