I have a problem with quartz (plugin: quartz2: 2.1.6.2, but I have a test even with the plugin: quartz: 1.0-RC7, but the problem does not change) in my Grails project (grails 2.2.1).
I have such a job
class MyJob { def concurrent = false def execute(context){ try {
Sometimes the execution method uses a StaleObjectStateException. This is normal for my logic, I use optimistic grails lock, and this exception occurs only once a week.
The problem is when this exception occurs when Job stops starting again.
I tried co wrap method code in try catch and flush hibernate session inside to catch an exception, but without fortune. An exception is not capture by any of my catch.
In an online search, I found this an old grails quartz error , but it has been fixed, and in any case, using try {} catch should get around the error.
PS The task is scheduled from bootstrab by calling this type
MyJob.schedule( 10000L )
The exception that stops planning is
[194949896] core.ErrorLogger Unable to notify JobListener(s) of Job that was executed: (error will be ignored). trigger= DEFAULT.MT_3tbn6lewgiqa3 job= DEFAULT.MyJob org.quartz.SchedulerException: JobListener 'persistenceContextJobListener' threw exception: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [MyDomain#42] [See nested exception: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [MyDomain#42]] at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzScheduler.java:1939) at org.quartz.core.JobRunShell.notifyJobListenersComplete(JobRunShell.java:361) at org.quartz.core.JobRunShell.run(JobRunShell.java:235) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [MyDomain#42] at grails.plugin.quartz2.PersistenceContextJobListener.jobWasExecuted(PersistenceContextJobListener.groovy:46) at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzScheduler.java:1937) ... 3 more ..... events.PatchedDefaultFlushEventListener Could not synchronize database state with session org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [MyJob#42] at MyJob.execute(MyJob.groovy:354) at grails.plugin.quartz2.GrailsArtefactJob.execute(GrailsArtefactJob.java:57) at org.quartz.core.JobRunShell.run(JobRunShell.java:213) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
source share