添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
){outline:none;box-shadow:none;}select::-ms-expand{;}:root,:host{--chakra-vh:100vh;}@supports (height: -webkit-fill-available){:root,:host{--chakra-vh:-webkit-fill-available;}}@supports (height: -moz-fill-available){:root,:host{--chakra-vh:-moz-fill-available;}}@supports (height: 100dvh){:root,:host{--chakra-vh:100dvh;}}
Link to home
Create Account Log in
Avatar of chaitu chaitu

Failure obtaining db row lock exception while integrating spring with Quartz scheduler

i am trying to run jobs using quartz(i am using 1.5.1 version) ;quartz scheduler integrated with Spring framework.i am getting exception
org.quartz.impl.jdbcjobsto re.LockExc eption: Failure obtaining db row lock: ORA-00942: table or view does not exist
[See nested exception: java.sql.SQLException: ORA-00942: table or view does not exist
<?xml version="1.0" encoding="UTF-8"?><!DOCTYP E beans PUBLIC "-//SPRING//DTD BEAN//EN" " http://www.springframework.org/dtd/spring-beans.dtd "><!--
- Application context definition for "springapp" DispatcherServlet.
<beans>
<bean id="myDataSourceTarget" class="org.apache.commons. dbcp.Basic DataSource " destroy-method="close">
<property name="driverClassName"><va lue>oracle .jdbc.driv er.OracleD river</val ue></prope rty>
<property name="url"><value>jdbc:ora cle:thin:@ xxxxxxx:xx x</value>< /property>
<property name="username"><value>xxx </value></ property>
<property name="password"><value>xxx </value></ property>
</bean>
<!--  Often you just need to invoke a method on a specific object. Using the MethodInvokingJobDetailFac toryBean you can do exactly this
<bean id="exampleJob" class="org.springframework .schedulin g.quartz.M ethodInvok ingJobDeta ilFactoryB ean">
<property name="targetObject" ref="exampleBusinessObject "/>
<property name="targetMethod" value="doIt"/>
</bean>
<bean id="exampleBusinessObject" class="bus.ExampleJob"/>
<bean name="exampleJob" class="org.springframework .schedulin g.quartz.J obDetailBe an">
<property name="jobClass" value="bus.ExampleJob"/>
<property name="jobDataAsMap">
<entry key="timeout" value="5"/>
</property>
</bean>
<bean class="org.springframework .schedulin g.quartz.S chedulerFa ctoryBean" >
<property name="autoStartup">
<value>false</value>
</property>
<property name="dataSource">
<ref bean="myDataSourceTarget" />
</property>
<property name="triggers">
<ref bean="cronTrigger"/>
</list>
</property>
<property name="applicationContextSc hedulerCon textKey">< value>appl icationCon text</valu e></proper ty>
<property name="waitForJobsToComplet eOnShutdow n"><value> true</valu e></proper ty>
<property name="quartzProperties">
<props>
<prop key="org.quartz.threadPool .threadCou nt">10</pr op>
<prop key="org.quartz.jobStore.c lass">org. quartz.sim pl.RAMJobS tore</prop >
<prop key="org.quartz.jobStore.d riverDeleg ateClass"> org.quartz .impl.jdbc jobstore.O racleDeleg ate</prop>
<prop key="org.quartz.jobStore.s electWithL ockSQL"> SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
</props>
</property>
</bean>
<bean id="simpleTrigger" class="org.springframework .schedulin g.quartz.S impleTrigg erBean">
<!-- see the example of method invoking job above -->
<property name="jobDetail" ref="exampleJob"/>
<!-- 10 seconds -->
<property name="startDelay" value="10000"/>
<!-- repeat every 50 seconds -->
<property name="repeatInterval" value="50000"/>
</bean>
<bean id="cronTrigger" class="org.springframework .schedulin g.quartz.C ronTrigger Bean">
<property name="jobDetail" ref="exampleJob"/>
<!-- run every morning at 6 AM -->
<property name="cronExpression" value="0 0 6 * * ?"/>
</bean>
</beans>
>>SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
Make sure the query produced selects a valid table or view and that it's accessible under the account from which it's being run
what's this query actually do No idea - i'd guess it's to do with synching jobs.
you don't have a table named QRTZ_LOCKS in your database
Avatar of Mick Barry
Mick Barry
Flag of Australia image
do you have perms for that data store to create tables
i created all these tables;
qrtz_job_listeners;
qrtz_trigger_listeners;
qrtz_fired_triggers;
qrtz_simple_triggers;
qrtz_cron_triggers;
qrtz_blob_triggers;
qrtz_triggers;
qrtz_job_details;
qrtz_calendars;
qrtz_paused_trigger_grps;
qrtz_locks;
qrtz_scheduler_state;
do i need this one in configuartion file;
<prop key="org.quartz.jobStore.s electWithL ockSQL"> SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
after creating above table do i need this query( SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?)
> do i need this one in configuartion file;
Sorry I'm not an oracle person, the default query is:
SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE
now i am getting this exception
Initialization of bean failed; nested exception is org.quartz.JobPersistenceE xception: Couldn't store job: org.springframework.schedu ling.quart z.MethodIn vokingJobD etailFacto ryBean
org.quartz.JobPersistenceE xception: Couldn't store job: org.springframework.schedu ling.quart z.MethodIn vokingJobD etailFacto ryBean [See nested exception: java.io.NotSerializableExc eption: org.springframework.schedu ling.quart z.MethodIn vokingJobD etailFacto ryBean]
>>MethodInvokingJobDetailF actoryBean
Please post the above
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

2006-03-25 15:47:10,882 ERROR [org.springframework.web.s ervlet.Dis patcherSer vlet] Context initialization failed
org.springframework.beans. factory.Be anCreation Exception: Error creating bean with name 'org.springframework.sched uling.quar tz.Schedul erFactoryB ean' defined in ServletContext resource [/WEB-INF/springapp-servle t.xml]: Initialization of bean failed; nested exception is org.quartz.JobPersistenceE xception: Couldn't store job: org.springframework.schedu ling.quart z.MethodIn vokingJobD etailFacto ryBean
org.quartz.JobPersistenceE xception: Couldn't store job: org.springframework.schedu ling.quart z.MethodIn vokingJobD etailFacto ryBean [See nested exception: java.io.NotSerializableExc eption: org.springframework.schedu ling.quart z.MethodIn vokingJobD etailFacto ryBean]
at org.quartz.impl.jdbcjobsto re.JobStor eSupport.s toreJob(Jo bStoreSupp ort.java:8 49)
at org.quartz.impl.jdbcjobsto re.JobStor eCMT.store Job(JobSto reCMT.java :309)
at org.quartz.core.QuartzSche duler.addJ ob(QuartzS cheduler.j ava:687)
at org.quartz.impl.StdSchedul er.addJob( StdSchedul er.java:26 1)
at org.springframework.schedu ling.quart z.Schedule rFactoryBe an.addJobT oScheduler (Scheduler FactoryBea n.java:754 )
at org.springframework.schedu ling.quart z.Schedule rFactoryBe an.registe rJobsAndTr iggers(Sch edulerFact oryBean.ja va:705)
at org.springframework.schedu ling.quart z.Schedule rFactoryBe an.afterPr opertiesSe t(Schedule rFactoryBe an.java:52 1)
at org.springframework.beans. factory.su pport.Abst ractAutowi reCapableB eanFactory .invokeIni tMethods(A bstractAut owireCapab leBeanFact ory.java:1 059)
(See my last comment)
i didnt get u Please post the code
you cannot use that factory bean with a persitenet store, they are not compatible.
If you weant a persistent job then you need to implement it yourself.
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

if u see the SchedulerFactoryBean class u can set the Datasource in it;
http://www.springframework.org/docs/api/org/springframework/scheduling/quartz/SchedulerFactoryBean.html
package bus;
import org.springframework.schedu ling.quart z.*;
import org.quartz.*;
public class ExampleJob extends QuartzJobBean {
private int timeout;
* Setter called after the ExampleJob is instantiated
* with the value from the JobDetailBean (5)
public void setTimeout(int timeout) {
this.timeout = timeout;
protected void executeInternal(JobExecuti onContext ctx)
throws JobExecutionException {
System.out.println("in.... .......... ......");
// do the actual work
public void doIt() {
// do the actual work
System.out.println("doIt.. .......... .......");
in the doIt() method i want to get database connection using JNDI;
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
i solved the problem like this;Is there any other approach other than this;
* Setter called after the ExampleJob is instantiated
* with the value from the JobDetailBean (5)
public void setTimeout(int timeout) {
this.timeout = timeout;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
protected void executeInternal(JobExecuti onContext ctx)
throws JobExecutionException {
System.out.println("in.... .......... ......");
// do the actual work
public void doIt() {
// do the actual work
Context ctx = new InitialContext();
DataSource ds =
(DataSource)ctx.lookup(
"java:oraclePool");
}catch(Exception e) {
e.printStackTrace();
<?xml version="1.0" encoding="UTF-8"?><!DOCTYP E beans PUBLIC "-//SPRING//DTD BEAN//EN" " http://www.springframework.org/dtd/spring-beans.dtd "><!--
- Application context definition for "springapp" DispatcherServlet.
<beans>
<bean id="dataSource" class="org.springframework .jndi.Jndi ObjectFact oryBean">
<property name="jndiName"><value>jav a:/oracleP ool</value ></propert y>
</bean>
<!--  Often you just need to invoke a method on a specific object. Using the MethodInvokingJobDetailFac toryBean you can do exactly this
<bean id="exampleJob" class="org.springframework .schedulin g.quartz.M ethodInvok ingJobDeta ilFactoryB ean">
<property name="targetObject" ref="exampleBusinessObject "/>
<property name="targetMethod" value="doIt"/>
</bean>
<bean id="exampleBusinessObject" class="bus.ExampleJob">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean class="org.springframework .schedulin g.quartz.S chedulerFa ctoryBean" lazy-init="false">
<property name="triggers">
<ref bean="cronTrigger"/>
<ref bean="simpleTrigger"/>
</list>
</property>
</bean>
<bean id="simpleTrigger" class="org.springframework .schedulin g.quartz.S impleTrigg erBean">
<!-- see the example of method invoking job above -->
<property name="jobDetail" ref="exampleJob"/>
<!-- 10 seconds -->
<property name="startDelay" value="10000"/>
<!-- repeat every 50 seconds -->
<property name="repeatInterval" value="50000"/>
</bean>
<bean id="cronTrigger" class="org.springframework .schedulin g.quartz.C ronTrigger Bean">
<property name="jobDetail" ref="exampleJob"/>
<!-- run every morning at 6 AM -->
<property name="cronExpression" value="0 0 6 * * ?"/>
</bean>
</beans>