Announcement Announcement Module
Collapse
No announcement yet.
Unable to store Job with name: 'jobDetail' and group: 'quartz-batch' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to store Job with name: 'jobDetail' and group: 'quartz-batch'

    Hi,

    My batch is scheduled through a web application. I am using Quartz for scheduler. I have only one batch to run, but i have to schedule same batch as multiple jobs. For example one job should run every day and another one is at end of every month. While scheduling through web application at first time, the batch is running as expected. But if I try for second time it generated below error. But if I restart my server and try, it is working fine. Please help me to solve this issue.

    org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'jobDetail' and group: 'quartz-batch', because one already exists with this identification.

    Thanks in advance,
    Shahul

  • #2
    Looks like the you are having trouble with Quartz scheduling, not Spring Batch. You are more likely to get relevant advice somewhere on Quartz forums with your issue.

    It seems you are trying to schedule a job that is already scheduled, so Quartz complains - you'll probably need to fix the "scheduling through web application" part.
    Last edited by robert.kasanicky; May 15th, 2008, 07:26 AM. Reason: spelling

    Comment


    • #3
      Thanks Robert....solved this issue. Here I am scheduling same jobs more than once. so we have to change job detail name and trigger name for each scheduling...

      Comment


      • #4
        Need help

        Hi can u pls tell ... how it got rectified sent the code,,,,,

        Comment


        • #5
          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
          Last edited by pbadatiya; Jul 26th, 2010, 01:11 AM.

          Comment


          • #6
            Chk this

            Hi,

            here the problem is :

            You are again and again using the same jobname...

            So use this piece of code:

            here in the below code i is the job Id which i am passing so it will be a unique one....

            public void task(String i, String JobName, String cronExp)
            throws SchedulerException, ClassNotFoundException {


            Scheduler scheduler = schedulerFactory.getScheduler();

            JobDetail jobDetail = new JobDetail(i, "jobDetailGroup" + i, Class
            .forName(JobName));
            CronTrigger cronTrigger = new CronTrigger("cronTrigger" + i,
            "triggerGroup" + i);



            try {

            CronExpression cexp = new CronExpression(cronExp);

            cronTrigger.setCronExpression(cexp);
            } catch (Exception e) {
            e.printStackTrace();
            }

            scheduler.scheduleJob(jobDetail, cronTrigger);
            boolean _started = true;
            scheduler.start();

            }


            This will work as it is worked for me.......

            Comment


            • #7
              Thanks for your replay....

              I have already tried your above implementation while I was doing R&D, however the problem is still persist.

              Some more details:

              In applicationContext.xml I have configured
              Code:
              <bean id="scheduler" class="com.vue.services.customscheduler.CustomeScheduleServiceImpl" init-method="getAllQuartzJobs"/>
              the reason is I wanted to run all quartz job at start up.

              and in web.xml
              Code:
              <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
              </context-param>
              <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
              </listener>
              when I explored it in debug mode, I found that the method getAllQuartzJobs() is getting called twice.

              I do not know why.. Please help me on this context.

              Note:
              For work around I shifted the below code in dispatcher-servlet.xml and it is working as expected however it is not a good practice to have.

              Code:
              <bean id="scheduler" class="com.vue.services.customscheduler.CustomeScheduleServiceImpl" init-method="getAllQuartzJobs"/>
              Please help me to implement this in proper fashion.



              Thanks,
              Pbadatiya
              Last edited by pbadatiya; Jul 27th, 2010, 02:50 AM.

              Comment

              Working...
              X