Announcement Announcement Module
Collapse
No announcement yet.
Exeption using Quartz integrates SchedulerFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exeption using Quartz integrates SchedulerFactoryBean

    Hi, all

    I'm getting this error trying to schedule some simple jobs using a SchedulerFactoryBean. Every thing goes well except that before I shutdown the sheduler. However, on shutdown, I get this error:

    Code:
    java.sql.SQLException: There is no DataSource named 'dummy'
    	at org.quartz.utils.DBConnectionManager.shutdown(DBConnectionManager.java:147)
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport.shutdown(JobStoreSupport.java:530)
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.shutdown(JobStoreCMT.java:157)
    	at org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:471)
    	at org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:434)
    	at org.quartz.impl.StdScheduler.shutdown(StdScheduler.java:176)
    	at gameshop.framework.quartz.DumbSchedulerFactory$1.doInTransactionWithoutResult(DumbSchedulerFactory.java:50)
    	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:114)
    	at gameshop.framework.quartz.DumbSchedulerFactory.main(DumbSchedulerFactory.java:27)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
    2004-10-3 1:21:55 org.quartz.impl.jdbcjobstore.JobStoreCMT shutdown
    警告: Database connection shutdown unsuccessful.
    java.sql.SQLException: There is no DataSource named 'dummy'
    	at org.quartz.utils.DBConnectionManager.shutdown(DBConnectionManager.java:147)
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.shutdown(JobStoreCMT.java:160)
    	at org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:471)
    	at org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:434)
    	at org.quartz.impl.StdScheduler.shutdown(StdScheduler.java:176)
    	at gameshop.framework.quartz.DumbSchedulerFactory$1.doInTransactionWithoutResult(DumbSchedulerFactory.java:50)
    	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:114)
    	at gameshop.framework.quartz.DumbSchedulerFactory.main(DumbSchedulerFactory.java:27)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
    2004-10-3 1:21:55 org.quartz.core.QuartzScheduler shutdown
    信息: Scheduler QuartzScheduler_$_NON_CLUSTERED shutdown complete.
    I looked through my codes and could't find anything named "dummy", so It must be a default setting somewhere

    Here is my codesnippet:

    Config File:

    Code:
    <beans>
        <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
            <property name="jobClass">
                <value>gameshop.framework.quartz.DumbJob</value>
            </property>
        </bean>
    
        <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
            <property name="jobDetail">
                <ref local="jobDetail"/>
            </property>
            <property name="repeatCount">
                <value>2</value>
            </property>
            <property name="repeatInterval">
                <value>1</value>
            </property>
        </bean>
    
        <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="dataSource">
                <ref bean="dataSource"/>
            </property>
            <property name="autoStartup">
                <value>false</value>
            </property>
            <property name="applicationContextSchedulerContextKey">
                <value>applicationContext</value>
            </property>
            <property name="waitForJobsToCompleteOnShutdown">
                <value>true</value>
            </property>
            <property name="quartzProperties">
                <props>
                    <!-- ThreadPool -->
                    <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
                    <prop key="org.quartz.threadPool.threadCount">5</prop>
                    <prop key="org.quartz.threadPool.threadPriority">5</prop>
                    <!-- Job store -->
                    <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
                    <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
                    <prop key="org.quartz.jobStore.driverDelegateClass">${jdbc.quartz.delegateClassName}</prop>
                    <prop key="org.quartz.jobStore.useProperties">false</prop>
                    <prop key="org.quartz.jobStore.selectWithLockSQL">
                        SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
                    </prop>
                    <!-- Plugins -->
                    <prop key="org.quartz.plugin.shutdownhook.class">
                        org.quartz.plugins.management.ShutdownHookPlugin
                    </prop>
                    <prop key="org.quartz.plugin.shutdownhook.cleanShutdown">true</prop>
                    <prop key="org.quartz.plugin.triggHistory.class">
                        org.quartz.plugins.history.LoggingTriggerHistoryPlugin
                    </prop>
                    <prop key="org.quartz.plugin.triggHistory.triggerFiredMessage">
                        Trigger {1}.{0} fired job {6}.{5} at: {4, date, HH:mm:ss MM/dd/yyyy}
                    </prop>
                    <prop key="org.quartz.plugin.triggHistory.triggerCompleteMessage">
                        Trigger {1}.{0} completed firing job {6}.{5} at {4, date, HH:mm:ss MM/dd/yyyy} with resulting trigger instruction code: {9}
                    </prop>
                </props>
            </property> <!-- end of quartzProperties-->
    
            <property name = "triggers">
                <list>
                    <ref local = "simpleTrigger"/>
                </list>
            </property>
        </bean>
    </beans>
    Test Code

    Code:
    public class DumbSchedulerFactory
    {
        public static void main(String[] args) throws SchedulerException, InterruptedException
        {
            Scheduler scheduler = (Scheduler) BeanLocator.getBean("scheduler");
            scheduler.start();
            Thread.sleep(10000);
           scheduler.shutdown();
         }
    }
    I found a post refered to the same problem! I did as his suggestion ,but maybe I missed something, it didn't work.

    Here is the post:
    http://forum.springframework.org/showthread.php?t=10118

    Any suggestion and hints will be appreciated!

    Regards.
    Yoshiyan
    Last edited by robyn; May 14th, 2006, 10:11 AM.

  • #2
    As I said in the mentioned thread, the DataSource passed with the
    'dataSource' property did not get registered in the Quartz DBConnectionManager.
    It is fine for me, as the DataSource is also used for DAO, and I don't want
    it to be closed when the scheduler shuts down.
    If you want it to get closed, do it when you call scheduler.shutdown().

    It should be an option to close the datasource when the scheduler shuts down, but the code to change is in the Quartz side.

    Comment


    • #3
      Thanks for spotting this. That exception can be safely ignored, as Spring provides a Spring-managed DataSource to Quartz, which doesn't need to be closed on Quartz shutdown.

      The only reason why Spring passes a "dummy" DataSource name to Quartz is that Quartz' JobStoreCMT class won't initialize without a DataSource name set, even if the connections are provided in a different way through a custom subclass.

      I've fixed this through overriding JobStoreCMT's "shutdown" method, to suppress that DataSource shutdown attempt. The DataSource will be closed on shutdown of the Spring context anyway.

      Juergen

      Comment


      • #4
        Originally posted by Juergen Hoeller
        Thanks for spotting this. That exception can be safely ignored, as Spring provides a Spring-managed DataSource to Quartz, which doesn't need to be closed on Quartz shutdown.

        The only reason why Spring passes a "dummy" DataSource name to Quartz is that Quartz' JobStoreCMT class won't initialize without a DataSource name set, even if the connections are provided in a different way through a custom subclass.

        I've fixed this through overriding JobStoreCMT's "shutdown" method, to suppress that DataSource shutdown attempt. The DataSource will be closed on shutdown of the Spring context anyway.

        Juergen
        Regarding the quartz integration, I noticed that spring uses the same connection as a "managed" and "non managed" quartz connection, which I think should not be. I had a number of problems, in fact, apparently involved with this (quartz calls commit on the conn. which is expected to be "non-managed" and this does not work with websphere managed conns.): I tried patching the spring support classes allowing them to pass two different connections to quartz and the problems disappeared: I did not have time to extensively test the thing, though. Is there something planned to solve this or I'd better suggest a patch?

        Comment


        • #5
          Create a JIRA issue so this doesn't get lost...

          Comment

          Working...
          X