Hello!
I am not sure sending this question on the accurate forum but I can't guess
answer and I am into troubles. Could somebody tell me what I am doing wrong
while creating a cron in order to create a person at a certain date (for
example the 3rd of August at 17pm):
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
// define the job and tie it to our EthicFlow_CreatePersonJob class
JobDetail job = new JobDetail("EthicFlow_CreatePersonJob",
Scheduler.DEFAULT_GROUP, EthicFlow_CreatePersonJob.class);
CronTrigger trigger = new CronTrigger("trigger1", Scheduler.DEFAULT_GROUP,
"EthicFlow_CreatePersonJob", Scheduler.DEFAULT_GROUP, "0 00 17 3 8 ? 2006");
//3 aout 2006 a 11h30
sched.addJob(job, true);
sched.scheduleJob(job, trigger);
sched.start();
Thread.sleep(300L * 1000L);
sched.shutdown(true);
It fails and I get this error:
Job execution threads will use class loader of thread: http-0.0.0.0-8080-2
2006-08-03 11:06:27,875 INFO [org.quartz.simpl.RAMJobStore] RAMJobStore
initialized.
2006-08-03 11:06:27,875 INFO [org.quartz.impl.StdSchedulerFactory] Quartz
scheduler 'DefaultQuartzScheduler' initialized from default resource file in
Quartz package: 'quartz.properties'
2006-08-03 11:06:27,937 INFO [org.quartz.impl.StdSchedulerFactory] Quartz
scheduler version: 1.4.5
2006-08-03 11:06:27,953 INFO
[org.alfresco.web.bean.EthicFlow_FormServices.EthicFlow_JspWizard] Exception
cron:org.quartz.ObjectAlreadyExistsException: Unable to store Job with name:
'CreatePersonJob' and group: 'DEFAULT', because one already exists with this
identification.
And I have a class EthicFlow_CreatePersonJob as follow:
public class EthicFlow_CreatePersonJob extends QuartzJobBean
{
private static Logger logger =
Logger.getLogger(EthicFlow_CreatePersonJob.class);
private String record;
/**
* Setter called after the CreateJob is instantiated
* with the value from the JobDetailBean (5)
*/
public void setRecord(String record) {
this.record = record;
}
protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {
// do the actual work
logger.info("Execution Job");
}
}
What do I do wrong here?
Thanks for your help
Sophie