You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Robert (JIRA)" <ji...@apache.org> on 2014/07/04 10:45:35 UTC
[jira] [Created] (DELTASPIKE-656) Concurrency Problem when using
QuartzScheduler
Robert created DELTASPIKE-656:
---------------------------------
Summary: Concurrency Problem when using QuartzScheduler
Key: DELTASPIKE-656
URL: https://issues.apache.org/jira/browse/DELTASPIKE-656
Project: DeltaSpike
Issue Type: Bug
Components: Scheduler
Affects Versions: 1.0.0
Environment: Quartz 2.1.1
Reporter: Robert
When using the Scheduler Module (1.0.0) together with Quartz (2.2.1) and start more than one job at the same second, I’m getting ConcurrentModificationExceptions.
This behavior can be reproduced with the following code snippet:
package de.rb.sandbox;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.SessionScoped;
import org.apache.deltaspike.cdise.api.CdiContainer;
import org.apache.deltaspike.cdise.api.CdiContainerLoader;
import org.apache.deltaspike.cdise.api.ContextControl;
import org.apache.deltaspike.scheduler.api.Scheduled;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class SchedulerTest extends Assert {
private CdiContainer cdiContainer;
@Before
public void setUp() {
cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
ContextControl contextControl = cdiContainer.getContextControl();
contextControl.startContext(ApplicationScoped.class);
}
@After
public void tearDown() {
cdiContainer.shutdown();
}
// runs every second
@Scheduled(cronExpression = "0/1 * * * * ?", startScopes = { SessionScoped.class })
public static class Job1 implements Job {
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Job1");
}
}
// runs every 2 seconds
@Scheduled(cronExpression = "0/2 * * * * ?", startScopes = { SessionScoped.class })
public static class Job2 implements Job {
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Job1");
}
}
@Test
public void testIt() throws Exception {
// run for a minute
Thread.sleep(60000);
}
}
Produces something like:
Job1
ERROR 2678 2014-07-03 12:10:42,714 [DefaultQuartzScheduler_Worker-1] org.quartz.core.ErrorLogger.schedulerError(2425) - Unable to notify JobListener(s) of Job to be executed: (Job will NOT be executed!). trigger= DEFAULT.6da64b5bd2ee-8e6928dd-89fe-47aa-a620-cb3b80f36aa6 job= DEFAULT.Job1
org.quartz.SchedulerException: JobListener 'org.apache.deltaspike.scheduler.impl.QuartzScheduler$InjectionAwareJobListener' threw exception: null
at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1947) ~[quartz-2.2.1.jar:na]
at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:324) [quartz-2.2.1.jar:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:173) [quartz-2.2.1.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.2.1.jar:na]
Caused by: java.util.ConcurrentModificationException: null
at java.util.Vector$Itr.checkForComodification(Vector.java:1156) ~[na:1.7.0_60]
at java.util.Vector$Itr.next(Vector.java:1133) ~[na:1.7.0_60]
at org.apache.deltaspike.scheduler.impl.QuartzScheduler$InjectionAwareJobListener.jobToBeExecuted(QuartzScheduler.java:370) ~[deltaspike-scheduler-module-impl-1.0.0.jar:1.0.0]
at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1945) ~[quartz-2.2.1.jar:na]
... 3 common frames omitted
ERROR 2678 2014-07-03 12:10:42,714 [DefaultQuartzScheduler_Worker-2] org.quartz.core.ErrorLogger.schedulerError(2425) - Unable to notify JobListener(s) of Job to be executed: (Job will NOT be executed!). trigger= DEFAULT.6da64b5bd2ee-8e6928dd-89fe-47aa-a620-cb3b80f36aa6 job= DEFAULT.Job1
org.quartz.SchedulerException: JobListener 'org.apache.deltaspike.scheduler.impl.QuartzScheduler$InjectionAwareJobListener' threw exception: null
at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1947) ~[quartz-2.2.1.jar:na]
at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:324) [quartz-2.2.1.jar:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:173) [quartz-2.2.1.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.2.1.jar:na]
Caused by: java.util.ConcurrentModificationException: null
at java.util.Vector$Itr.checkForComodification(Vector.java:1156) ~[na:1.7.0_60]
at java.util.Vector$Itr.next(Vector.java:1133) ~[na:1.7.0_60]
at org.apache.deltaspike.scheduler.impl.QuartzScheduler$InjectionAwareJobListener.jobToBeExecuted(QuartzScheduler.java:370) ~[deltaspike-scheduler-module-impl-1.0.0.jar:1.0.0]
at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1945) ~[quartz-2.2.1.jar:na]
... 3 common frames omitted
Job1
<and so on…>
The only way to omit the concurrency problems is to limit the scheduled scope to none:
@Scheduled(cronExpression = "0/1 * * * * ?", startScopes = {})
But this might not be intended.
--
This message was sent by Atlassian JIRA
(v6.2#6252)