Results 1 to 5 of 5

Thread: Exeption using Quartz integrates SchedulerFactoryBean

  1. #1
    Join Date
    Sep 2004
    Location
    China
    Posts
    17

    Default 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 at 10:11 AM.

  2. #2
    Join Date
    Aug 2004
    Location
    Montreal - Canada
    Posts
    46

    Default

    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.
    Christophe

  3. #3
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    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

  4. #4
    Join Date
    Sep 2004
    Posts
    23

    Default

    Quote 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?

  5. #5
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Create a JIRA issue so this doesn't get lost...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Error using Quartz integration SchedulerFactoryBean
    By dhalbrook in forum Container
    Replies: 9
    Last Post: Oct 11th, 2011, 09:58 AM
  2. Using Quartz inside SpringFramework
    By cf101 in forum Web
    Replies: 8
    Last Post: Apr 27th, 2006, 04:35 AM
  3. Migrating to new version of Quartz
    By ramkris in forum Container
    Replies: 4
    Last Post: Nov 15th, 2005, 02:51 AM
  4. Quartz question
    By kuns in forum Container
    Replies: 3
    Last Post: Jul 11th, 2005, 03:03 PM
  5. dummy datasource in quartz
    By mperham in forum Container
    Replies: 2
    Last Post: Sep 14th, 2004, 03:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •