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
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
Sorry I'm not an oracle person, the default query is:
SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE
Initialization of bean failed; nested exception is org.quartz.JobPersistenceE
org.quartz.JobPersistenceE
>>MethodInvokingJobDetailF
Please post the above
org.springframework.beans.
org.quartz.JobPersistenceE
at org.quartz.impl.jdbcjobsto
at org.quartz.impl.jdbcjobsto
at org.quartz.core.QuartzSche
at org.quartz.impl.StdSchedul
at org.springframework.schedu
at org.springframework.schedu
at org.springframework.schedu
at org.springframework.beans.
(See my last comment)
If you weant a persistent job then you need to implement it yourself.
http://www.springframework.org/docs/api/org/springframework/scheduling/quartz/SchedulerFactoryBean.html
package bus;
import org.springframework.schedu
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
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;
* 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
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
- Application context definition for "springapp" DispatcherServlet.
<beans>
<bean id="dataSource" class="org.springframework
<property name="jndiName"><value>jav
</bean>
<!-- Often you just need to invoke a method on a specific object. Using the MethodInvokingJobDetailFac
<bean id="exampleJob" class="org.springframework
<property name="targetObject" ref="exampleBusinessObject
<property name="targetMethod" value="doIt"/>
</bean>
<bean id="exampleBusinessObject"
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean class="org.springframework
<property name="triggers">
<ref bean="cronTrigger"/>
<ref bean="simpleTrigger"/>
</list>
</property>
</bean>
<bean id="simpleTrigger" class="org.springframework
<!-- 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
<property name="jobDetail" ref="exampleJob"/>
<!-- run every morning at 6 AM -->
<property name="cronExpression" value="0 0 6 * * ?"/>
</bean>
</beans>