Quartz Error Misfire Handling and Failure on Job Recovery

风流意气都作罢 提交于 2019-12-10 18:46:09

问题


I'm new to JSP and Quartz Scheduling! In this project, I'm trying to make the quartz scheduler continue functioning in case the server is turned off then on ignoring the missed jobs.

For this, I researched JobPersistence and I have modified the quartz.properties file as the following:

org.quartz.threadPool.threadCount=5
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.dataSource = myDB
org.quartz.dataSource.myDB.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.myDB.URL = jdbc:mysql://localhost:3306/contacts
org.quartz.dataSource.myDB.user = root
org.quartz.dataSource.myDB.password = root

the web.xml file contains the following:

...
<listener>
   <listener-class>
      org.quartz.ee.servlet.QuartzInitializerListener
   </listener-class>
</listener>
...

I've added the tables to the DB and when I select I can see that it really inserted triggers to its tables.

The trigger is built as the following:

Trigger trig = TriggerBuilder
  .newTrigger()
  .startAt(scal.getTime())
  .withSchedule(
     SimpleScheduleBuilder.simpleSchedule()
    .withIntervalInMinutes(minutes).repeatForever())
  .endAt(ecal.getTime()).build();

Now, when I run my web app, I schedule a job and it executes. Then, I turn off the tomcat server and start it again. It prints the following error to the logger:

org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Couldn't recover jobs: null [See nested exception: java.lang.NullPointerException]]

I have tried executing the following statement once in MySQLWorkbench:

UPDATE QRTZ_TRIGGERS SET NEXT_FIRE_TIME=1 WHERE NEXT_FIRE_TIME < 0;

Now, I got this new error:

.manage - MisfireHandler: Error handling misfires: Unexpected runtime exception: null

org.quartz.JobPersistenceException: Unexpected runtime exception: null [See nested exception: java.lang.NullPointerException]

If you want me to edit and include the stackTrace, I can do that...


回答1:


remove the useProperties = true and replace it with

org.quartz.scheduler.misfirePolicy =  doNothing

remove the UPDATE

remove any .withMisfireHandling() methods on top of your Trigger and remove the .requestRecovery(true) on your JobDetail in case you used it.

Also, make sure you don't cancel the Job in case it exists...



来源:https://stackoverflow.com/questions/31423003/quartz-error-misfire-handling-and-failure-on-job-recovery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!