Announcement Announcement Module
Collapse
No announcement yet.
Error when using persistence jobs with quartz Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    [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.

    Comment


    • #3
      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;

      Comment


      • #4
        Thxs Christophe!

        Comment


        • #5
          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!

          Comment

          Working...
          X