Results 1 to 5 of 5

Thread: Error when using persistence jobs with quartz

  1. #1
    Join Date
    Dec 2004
    Location
    Buenos Aires, Argentina
    Posts
    73

    Default Error when using persistence jobs with quartz

    Hi everybody,

    RAM persistance is working fine with the following context configuration file
    Code:
     <bean id="schedulerFactoryBean" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager">
          <ref bean="transactionManager"/>
        </property>
        <property name="target">
          <ref local="schedulerFactoryBeanTarget"/>
        </property>
        <property name="transactionAttributes">
          <props>
            <prop key="*">PROPAGATION_REQUIRED</prop>
          </props>
        </property>
      </bean>
      <bean id="schedulerFactoryBeanTarget" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="autoStartup">
          <value>false</value>
        </property>
     </bean>
    Now when I add a dataSource property (using jtds driver to access MS SQLServer 2000),
    Code:
    <bean id="schedulerFactoryBeanTarget" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="autoStartup">
          <value>false</value>
        </property>
        <property name="dataSource">
          <ref bean="dataSource"/>
        </property>
     </bean>
    got an exception. I might be missing something. Any help would be great.

    Thanks in advance,
    Gustavo.


    Code:
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'scheduler' defined in class path resource &#91;com/vaau/rbacx/context/test-scheduling-context.xml&#93;&#58; Can't resolve reference to bean 'schedulerFactoryBean' while setting property 'springScheduler'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'schedulerFactoryBean' defined in class path resource &#91;com/vaau/rbacx/context/test-scheduling-context.xml&#93;&#58; Can't resolve reference to bean 'schedulerFactoryBeanTarget' while setting property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'schedulerFactoryBeanTarget' defined in class path resource &#91;com/vaau/rbacx/context/test-scheduling-context.xml&#93;&#58; Initialization of bean failed; nested exception is org.quartz.SchedulerConfigException&#58; Failure occured during job recovery.
    
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'schedulerFactoryBean' defined in class path resource &#91;com/vaau/rbacx/context/test-scheduling-context.xml&#93;&#58; Can't resolve reference to bean 'schedulerFactoryBeanTarget' while setting property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'schedulerFactoryBeanTarget' defined in class path resource &#91;com/vaau/rbacx/context/test-scheduling-context.xml&#93;&#58; Initialization of bean failed; nested exception is org.quartz.SchedulerConfigException&#58; Failure occured during job recovery.
    
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'schedulerFactoryBeanTarget' defined in class path resource &#91;com/vaau/rbacx/context/test-scheduling-context.xml&#93;&#58; Initialization of bean failed; nested exception is org.quartz.SchedulerConfigException&#58; Failure occured during job recovery.
    
    org.quartz.SchedulerConfigException&#58; Failure occured during job recovery. &#91;See nested exception&#58; org.quartz.impl.jdbcjobstore.LockException&#58; Failure obtaining db row lock&#58; Line 1&#58; FOR UPDATE clause allowed only for DECLARE CURSOR. &#91;See nested exception&#58; java.sql.SQLException&#58; Line 1&#58; FOR UPDATE clause allowed only for DECLARE CURSOR.&#93;&#93;
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize&#40;JobStoreSupport.java&#58;504&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.initialize&#40;JobStoreCMT.java&#58;150&#41;
    	at org.springframework.scheduling.quartz.LocalDataSourceJobStore.initialize&#40;LocalDataSourceJobStore.java&#58;118&#41;
    	at org.quartz.impl.StdSchedulerFactory.instantiate&#40;StdSchedulerFactory.java&#58;915&#41;
    	at org.quartz.impl.StdSchedulerFactory.getScheduler&#40;StdSchedulerFactory.java&#58;1047&#41;
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler&#40;SchedulerFactoryBean.java&#58;543&#41;
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet&#40;SchedulerFactoryBean.java&#58;494&#41;

    Code:
    * Nested Exception &#40;Underlying Cause&#41; ---------------
    
    java.sql.SQLException&#58; Line 1&#58; FOR UPDATE clause allowed only for DECLARE CURSOR.
    	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic&#40;SQLDiagnostic.java&#58;367&#41;
    	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken&#40;TdsCore.java&#58;2282&#41;
    	at net.sourceforge.jtds.jdbc.TdsCore.nextToken&#40;TdsCore.java&#58;1747&#41;
    	at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults&#40;TdsCore.java&#58;515&#41;
    	at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery&#40;JtdsStatement.java&#58;275&#41;
    	at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery&#40;JtdsPreparedStatement.java&#58;644&#41;
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery&#40;DelegatingPreparedStatement.java&#58;92&#41;
    	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.obtainLock&#40;StdRowLockSemaphore.java&#58;142&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.cleanVolatileTriggerAndJobs&#40;JobStoreCMT.java&#58;218&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize&#40;JobStoreSupport.java&#58;501&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.initialize&#40;JobStoreCMT.java&#58;150&#41;
    	at org.springframework.scheduling.quartz.LocalDataSourceJobStore.initialize&#40;LocalDataSourceJobStore.java&#58;118&#41;
    	at org.quartz.impl.StdSchedulerFactory.instantiate&#40;StdSchedulerFactory.java&#58;915&#41;
    	at org.quartz.impl.StdSchedulerFactory.getScheduler&#40;StdSchedulerFactory.java&#58;1047&#41;
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler&#40;SchedulerFactoryBean.java&#58;543&#41;
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet&#40;SchedulerFactoryBean.java&#58;494&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;1065&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;343&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;260&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;221&#41;
    Code:
    * Nested Exception &#40;Underlying Cause&#41; ---------------
    
    org.quartz.impl.jdbcjobstore.LockException&#58; Failure obtaining db row lock&#58; Line 1&#58; FOR UPDATE clause allowed only for DECLARE CURSOR. &#91;See nested exception&#58; java.sql.SQLException&#58; Line 1&#58; FOR UPDATE clause allowed only for DECLARE CURSOR.&#93;
    	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.obtainLock&#40;StdRowLockSemaphore.java&#58;160&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.cleanVolatileTriggerAndJobs&#40;JobStoreCMT.java&#58;218&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize&#40;JobStoreSupport.java&#58;501&#41;
    	at org.quartz.impl.jdbcjobstore.JobStoreCMT.initialize&#40;JobStoreCMT.java&#58;150&#41;
    	at org.springframework.scheduling.quartz.LocalDataSourceJobStore.initialize&#40;LocalDataSourceJobStore.java&#58;118&#41;
    	at org.quartz.impl.StdSchedulerFactory.instantiate&#40;StdSchedulerFactory.java&#58;915&#41;
    	at org.quartz.impl.StdSchedulerFactory.getScheduler&#40;StdSchedulerFactory.java&#58;1047&#41;
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler&#40;SchedulerFactoryBean.java&#58;543&#41;
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet&#40;SchedulerFactoryBean.java&#58;494&#41;

  2. #2
    Join Date
    Dec 2004
    Location
    Buenos Aires, Argentina
    Posts
    73

    Default [OT] Just add a line and tests are fine...

    I just added this line to my configuration (got it from thread http://forum.springframework.org/vie...rtz+properties)

    Code:
    <prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM &#123;0&#125;LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
    and tests are ok. But do not know the consequences.
    It is clearly a Quartz forum oriented question, but just in case, would anyone share with us what was going wrong and what this line fixes?

    Thanks,
    Gustavo.

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

    Default

    Found in Quartz JavaStoreSupport:
    Code:
        /**
         * <p>
         * set the SQL statement to use to select and lock a row in the "locks"
         * table.
         * </p>
         * 
         * @see StdRowLockSemaphore
         */
        public void setSelectWithLockSQL&#40;String string&#41; &#123;
            selectWithLockSQL = string;
        &#125;
    Christophe

  4. #4
    Join Date
    Dec 2004
    Location
    Buenos Aires, Argentina
    Posts
    73

    Default

    Thxs Christophe!

  5. #5
    Join Date
    Dec 2010
    Posts
    8

    Question Affects on Quartz?

    Sorry for resurrecting a yea ol'thread but I had recently encoutered this issue and the suggested property setting above did fix it. However I am not sure if there could be an unwanted sideffect.

    The documentation for Quartz says:
    org.quartz.jobStore.selectWithLockSQL
    Must be a SQL string that selects a row in the "LOCKS" table and places a lock on the row. If not set, the default is "SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE", which works for most databases. The "{0}" is replaced during run-time with the TABLE_PREFIX that you configured above.

    Does changing the select to "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?" as suggested still fullfill the requirement Quartz describes above? Or could it lead to some terrible times with locking issues and conflicts?

    Thanks in advance!

Similar Threads

  1. Scheduling Jobs with Quartz and Spring
    By MmarcoM in forum Container
    Replies: 4
    Last Post: Mar 2nd, 2010, 02:23 PM
  2. Runtime Quartz jobs and ApplicationContext
    By vmarcinko in forum Container
    Replies: 7
    Last Post: Feb 5th, 2008, 11:21 PM
  3. Problem with Quartz and Spring (durable jobs)
    By keithc in forum Container
    Replies: 4
    Last Post: Nov 1st, 2006, 02:17 PM
  4. Quartz - Statefull Jobs
    By nandhusriram in forum Container
    Replies: 1
    Last Post: Sep 7th, 2005, 01:11 PM
  5. Replies: 1
    Last Post: May 15th, 2005, 06:37 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
  •