Announcement Announcement Module
Collapse
No announcement yet.
Quartz - Statefull Jobs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz - Statefull Jobs

    I am trying to schedule a persistent Job with Quartz. I modified the Quartz .properties to to change the job store from RAM to JDBC. I even created all the tables required by the quartz. When I run my application , I am getting this error

    [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR. [See nested exception: java.sql.SQLException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.]]




    Here is beans.xml




    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="myHibernateSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="url" value="jdbc:jtds:sqlserver://localhost:1433/TEST;user=sa;password=test"/>
    <property name="username" value="sa"/>
    <property name="password" value="test"/>
    </bean>
    <bean id="mySQLSessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="myHibernateSource"/>
    <property name="mappingResources">
    <list>
    <value>com/pearson/prototype/hibernate/Coffee.hbm.xml</value>
    <value>com/pearson/prototype/hibernate/Coffees.hbm.xml</value>
    <value>com/pearson/icis/csruserloaderprocess/dataaccess/CsrUser.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLS erverDialect</prop>
    </props>
    </property>
    </bean>
    <bean id="myCoffeeDao" class="com.pearson.prototype.hibernate.CoffeeDaoIm pl">
    <property name="sessionFactory" ref="mySQLSessionFactory"/>
    </bean>
    <bean id="csrUserDAO" class="com.pearson.icis.csruserloaderprocess.dataa ccess.CSRUserDAOImpl">
    <property name="sessionFactory" ref="mySQLSessionFactory"/>
    </bean>
    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory" ref="mySQLSessionFactory"/>
    </bean>
    <!-- JCA Related -->
    <bean id="managedConnectionFactory" class="com.pearson.prototype.ftp.FTPManagedConnect ionFactory">
    <property name="serverName">
    <value>localhost</value>
    </property>
    <property name="portNumber">
    <value>21</value>
    </property>
    <property name="userName">
    <value>guest</value>
    </property>
    <property name="password">
    <value>guest</value>
    </property>
    <property name="operatingSystem">
    <value>WINDOWS</value>
    </property>
    </bean>
    <bean id="MyFTPManagedConnectionFactory" class="org.springframework.jca.support.LocalConnec tionFactoryBean">
    <property name="managedConnectionFactory">
    <ref local="managedConnectionFactory"/>
    </property>
    </bean>
    <bean id="connectionFactory" class="org.springframework.jca.cci.connection.Conn ectionSpecConnectionFactoryAdapter">
    <property name="targetConnectionFactory">
    <ref bean="MyFTPManagedConnectionFactory"/>
    </property>
    <!-- <property name="connectionSpec">
    <bean class="com.pearson.prototype.ftp.FTPConnectionSpec ">
    <property name="serverName">
    <value>localhost</value>
    </property>
    <property name="portNumber">
    <value>21</value>
    </property>
    <property name="userName">
    <value>guest</value>
    </property>
    <property name="password">
    <value>guest</value>
    </property>
    </bean>
    </property>-->
    </bean>
    <bean id="fileRetrieveTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <property name="jobDetail" ref="ftpFileRetrieveJob"/>
    <property name="startDelay" value="30000"/>
    <property name="repeatInterval" value="300000"/>
    </bean>
    <bean id="quartzScheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="schedulerName" value="quartzScheduler"/>
    <property name="triggers">
    <list>
    <ref bean="fileRetrieveTrigger"/>
    </list>
    </property>
    <property name="dataSource">
    <ref local="myHibernateSource"/>
    </property>
    </bean>
    <bean id="ftpFileRetrieveJob" class="org.springframework.scheduling.quartz.JobDe tailBean">
    <property name="jobClass">
    <value>com.pearson.prototype.ftp.scheduler.FTPFile RetrieveJob</value>
    </property>
    <property name="jobDataAsMap">
    <map>
    <entry key="managedConnectionFactory">
    <ref bean="managedConnectionFactory"/>
    </entry>
    <entry key="outputDirectory" value="incoming">
    </entry>
    </map>
    </property>
    </bean>
    </beans>


    Thanks
    and Appreciate any help.

  • #2
    Re: Quartz - Statefull Jobs

    Try adding the following property to your scheduler factory bean:
    Code:
    <property name="quartzProperties">
    	  <props>
    	  	<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM &#123;0&#125;LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
    </property>
    It might have some concurrency issues, but I have not noticed any yet.

    Comment

    Working...
    X