Results 1 to 4 of 4

Thread: QuartzBatchLauncher JobInstanceAlreadyCompleteException

  1. #1
    Join Date
    Feb 2008
    Location
    Boston
    Posts
    9

    Default QuartzBatchLauncher JobInstanceAlreadyCompleteException

    Why does QuartzBatchLauncher throw JobInstanceAlreadyCompleteException after first successful run?

    Code:
    17:06:50,889  INFO main QuartzBatchLauncher:89 - Started Quartz scheduler.
    17:06:55,592  INFO DefaultQuartzScheduler_Worker-0 JobLauncherDetails:69 - Quartz trigger firing with Spring Batch jobName=footballJob
    17:06:55,608 DEBUG DefaultQuartzScheduler_Worker-0 JobLauncherDetails:106 - JobDataMap contains values which are not job parameters (ignoring).
    17:06:55,608 DEBUG DefaultQuartzScheduler_Worker-0 JobLauncherDetails:106 - JobDataMap contains values which are not job parameters (ignoring).
    17:06:55,608 DEBUG DefaultQuartzScheduler_Worker-0 JobLauncherDetails:106 - JobDataMap contains values which are not job parameters (ignoring).
    17:06:56,061  INFO SimpleAsyncTaskExecutor-1 SimpleJobLauncher:85 - Job: [org.springframework.batch.sample.ClassPathXmlApplicationContextJobFactory$ContextClosingJob@2b2af3] launched with the following parameters: [{}{}{}{}]
    17:06:56,264  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: PLAYER:ID=AbduKa00,Last Name=Abdul-Jabbar,First Name=Karim,Position=rb,Birth Year=1974,DebutYear=1996
    17:06:56,264  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: PLAYER:ID=AbduRa00,Last Name=Abdullah,First Name=Rabih,Position=rb,Birth Year=1975,DebutYear=1999
    17:06:56,280  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: PLAYER:ID=AberWa00,Last Name=Abercrombie,First Name=Walter,Position=rb,Birth Year=1959,DebutYear=1982
    17:06:56,280  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: PLAYER:ID=AbraDa00,Last Name=Abramowicz,First Name=Danny,Position=wr,Birth Year=1945,DebutYear=1967
    17:06:56,280  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: PLAYER:ID=AdamBo00,Last Name=Adams,First Name=Bob,Position=te,Birth Year=1946,DebutYear=1969
    17:06:56,327  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: Game: ID=AbduKa00 mia vs. nwe - 1996
    17:06:56,327  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: Game: ID=AbduKa00 mia vs. clt - 1996
    17:06:56,342  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: Game: ID=AbduKa00 mia vs. oti - 1996
    17:06:56,342  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: Game: ID=AbduKa00 mia vs. pit - 1996
    17:06:56,342  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: Game: ID=AbduKa00 mia vs. rai - 1996
    17:06:56,389  INFO SimpleAsyncTaskExecutor-1 ProcessorLogAdvice:53 - Processed: Player Summary: ID=AbduKa00 Year=1996
    17:06:56,405  INFO SimpleAsyncTaskExecutor-1 SimpleJobLauncher:87 - Job: [org.springframework.batch.sample.ClassPathXmlApplicationContextJobFactory$ContextClosingJob@2b2af3] completed successfully with the following parameters: [{}{}{}{}]
    17:07:05,577  INFO DefaultQuartzScheduler_Worker-8 JobLauncherDetails:69 - Quartz trigger firing with Spring Batch jobName=footballJob
    17:07:05,577 DEBUG DefaultQuartzScheduler_Worker-8 JobLauncherDetails:106 - JobDataMap contains values which are not job parameters (ignoring).
    17:07:05,577 DEBUG DefaultQuartzScheduler_Worker-8 JobLauncherDetails:106 - JobDataMap contains values which are not job parameters (ignoring).
    17:07:05,577 DEBUG DefaultQuartzScheduler_Worker-8 JobLauncherDetails:106 - JobDataMap contains values which are not job parameters (ignoring).
    17:07:05,764 ERROR DefaultQuartzScheduler_Worker-8 JobLauncherDetails:75 - Could not execute job.
    org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={}{}{}{}.  If you want to run this job again, change the parameters.
        at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:171)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy0.createJobExecution(Unknown Source)
        at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:79)
        at org.springframework.batch.sample.quartz.JobLauncherDetails.executeInternal(JobLauncherDetails.java:72)
        at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)

  2. #2
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Please keep in mind that you need a new JobInstance after a successfull run, and JobInstance = Job + JobParameters:

    http://static.springframework.org/sp...re.html#d0e275

    If you always want a new instance, you could just wrap with the current time or something like that, if not it might be a new schedule date, etc, it depends upon your job.

  3. #3
    Join Date
    Feb 2008
    Location
    Boston
    Posts
    9

    Thumbs up

    wrap with the current time
    Gotcha! By doing

    Code:
    builder.addLong("currTime", new Long(System.currentTimeMillis()));
    in JobLauncherDetails.getJobParametersFromJobMap() I was able to create new JobInstance for each trigger from quartz.

    über dude!

  4. #4
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Glad that worked for you. Keep in mind that you won't be able to 'restart' if a job fails if you're always using a new JobInstance. However, if starting over from the beginning isn't an issue, then you should be fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •