Hi All,
I am still getting the error org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'Customer export' and group: 'Customer export', because one already exists with this identification.
Code:
public class CustomeScheduleServiceImpl {
private Scheduler scheduler;
public CustomeScheduleServiceImpl() {
try {
this.scheduler = new StdSchedulerFactory().getScheduler();
} catch (SchedulerException cause) {
logger.error(cause);
}
}
private static final Logger logger = Logger.getLogger(CustomeScheduleServiceImpl.class);
/**
*
*/
public void getAllQuartzJobs() {
CustomScheduleDelegate delegate = new CustomScheduleDelegate();
List<CustomScheduleTO> jobs;
try {
jobs = delegate.getCustomScheduleData();
Iterator<CustomScheduleTO> it = jobs.iterator();
while (it.hasNext()) {
CustomScheduleTO jobTO = it.next();
runQurtz(jobTO.getJobName(), jobTO.getJobClassName(), jobTO.getJobRunExpr());
}
} catch (ServiceException cause) {
cause.printStackTrace();
}
}
/**
*
* @param jobName
* @param className
* @param expr
*/
public void runQurtz(String jobName, String className, String expr) {
try {
JobDetail jobDetail = new JobDetail(jobName, jobName, Class.forName(className));
CronTrigger cronTrigger = new CronTrigger(jobName, jobName);
cronTrigger.setCronExpression(new CronExpression(expr));
scheduler.scheduleJob(jobDetail, cronTrigger);
scheduler.start();
System.out.println(jobName + "Ran the Quartz job with group name" + jobName);
} catch (ParseException cause) {
logger.error(cause);
} catch (SchedulerException cause) {
logger.error(cause);
} catch (ClassNotFoundException cause) {
logger.error(cause);
}
}
}
Here in this code we are getting the entire quartz job from data base with different job Detail and group name still I am getting this error.
Job Details and cron expr
Customer export 0 0/1 * * * ?
Product export 0 0/1 * * * ?
export Report 0 0/1 * * * ?
Please share your code which is running without any stated error.
I would really appreciate if you could elaborate the same.
Thanks