Announcement Announcement Module
Collapse
No announcement yet.
Spring + Quartz Scheduler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Quartz Scheduler

    Hi,
    I am using Quartz scheduler in spring frame work. I write code..

    public class EmailScheduler {

    public EmailScheduler() throws ParseException{
    try {
    EmailDAO emailDAO = new EmailDAOImpl();
    Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
    JobDetail jobDetail = new JobDetail("hihello", Scheduler.DEFAULT_GROUP ,EmailReportJob.class);
    jobDetail.getJobDataMap().put("emailDAO", emailDAO);

    Trigger trigger = new CronTrigger("trigger1","group1") ;
    ((CronTrigger) trigger).setCronExpression("0 26 18 * * ?");
    scheduler.scheduleJob(jobDetail,trigger); } catch (SchedulerException ex) {
    ex.printStackTrace();
    }

    }
    }

    when I run this code it generate error

    " org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'hihello' and group: 'DEFAULT', because one already exists with this identification."

    I also changed th job name, but got same error. Can any body help me...

    Regards,

  • #2
    Your code seems a bit strange. Normally one would create a bean that is invoked by Quartz based up on the config you provide in your applicationContext file.

    In your code it seems that you create your job at runtime, essentially not using the springframework at all...

    The spring manual is quite clear on this:
    http://static.springframework.org/sp...eduling-quartz

    Comment

    Working...
    X