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

  • JobInstanceAlreadyCompleteException

    Hi,

    I need to execute my job again and again even if it is complete.
    Even if i give restartable as true im getting exception.
    What should be done for this?

    Code:
    			
    	<bean id="hibernateJob" parent="simpleJob">
    		<!-- set restartable=false so that this job can be used by more than one test -->
    		<property name="restartable" value="true" />
    		<property name="steps">
    			<bean id="step1" parent="skipLimitStep">
    				<property name="skipLimit" value="1" />
    				<property name="itemReader" ref="hibernateItemReader" />
    				<property name="itemWriter" ref="hibernateItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="listeners" ref="stepListener" /> 
    				<property name="exceptionHandler" ref="exceptionHandler" />
    				<property name="allowStartIfComplete" value="true" />
    			</bean>
    		</property>
    	</bean>
    
    Exception:
    testLaunchJob(com.met.ib.upi.batch.test.HibernateJobFunctionalTests)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.

  • #2
    Even if you want to run the 'Job' again multiple times, it still needs to be a separate 'JobInstance', so the framework can keep track of things like restartability, etc. Using different JobParameters for the separate runs is all you need to do.

    Comment


    • #3
      hello,

      I have the same problem as you and your post help me to resolve it!
      When I add the instruction:builder.addLong("currTime", new Long(System.currentTimeMillis()));

      my program work better with no exception.

      However, only the first time my writter is called (just to print "hello world" on the screed).

      Look this :

      INFO: Quartz trigger firing with Spring Batch jobName=job1
      Apr 22, 2009 5:22:40 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] launched with the following parameters: [{currTime=1240413760020}]
      Apr 22, 2009 5:22:40 PM org.springframework.batch.core.job.AbstractJob handleStep
      INFO: Executing step: [TaskletStep: [name=step1]]
      Apr 22, 2009 5:22:40 PM example.ExampleItemWriter write
      INFO: [Hello world!]
      Apr 22, 2009 5:22:40 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] completed with the following parameters: [{currTime=1240413760020}] and the following status: [COMPLETED]
      Apr 22, 2009 5:22:50 PM com.beweb.batch.quartz.JobLauncherDetails executeInternal
      INFO: Quartz trigger firing with Spring Batch jobName=job1
      Apr 22, 2009 5:22:50 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] launched with the following parameters: [{currTime=1240413770011}]
      Apr 22, 2009 5:22:50 PM org.springframework.batch.core.job.AbstractJob handleStep
      INFO: Executing step: [TaskletStep: [name=step1]]
      Apr 22, 2009 5:22:50 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] completed with the following parameters: [{currTime=1240413770011}] and the following status: [COMPLETED]
      Apr 22, 2009 5:23:00 PM com.beweb.batch.quartz.JobLauncherDetails executeInternal
      INFO: Quartz trigger firing with Spring Batch jobName=job1
      Apr 22, 2009 5:23:00 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] launched with the following parameters: [{currTime=1240413780001}]
      Apr 22, 2009 5:23:00 PM org.springframework.batch.core.job.AbstractJob handleStep
      INFO: Executing step: [TaskletStep: [name=step1]]
      Apr 22, 2009 5:23:00 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] completed with the following parameters: [{currTime=1240413780001}] and the following status: [COMPLETED]
      Apr 22, 2009 5:23:10 PM com.beweb.batch.quartz.JobLauncherDetails executeInternal
      INFO: Quartz trigger firing with Spring Batch jobName=job1
      Apr 22, 2009 5:23:10 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] launched with the following parameters: [{currTime=1240413790008}]
      Apr 22, 2009 5:23:10 PM org.springframework.batch.core.job.AbstractJob handleStep
      INFO: Executing step: [TaskletStep: [name=step1]]
      Apr 22, 2009 5:23:10 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] completed with the following parameters: [{currTime=1240413790008}] and the following status: [COMPLETED]
      Apr 22, 2009 5:23:20 PM com.beweb.batch.quartz.JobLauncherDetails executeInternal
      INFO: Quartz trigger firing with Spring Batch jobName=job1
      Apr 22, 2009 5:23:20 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] launched with the following parameters: [{currTime=1240413800014}]
      Apr 22, 2009 5:23:20 PM org.springframework.batch.core.job.AbstractJob handleStep
      INFO: Executing step: [TaskletStep: [name=step1]]
      Apr 22, 2009 5:23:20 PM org.springframework.batch.core.launch.support.Simp leJobLauncher$1 run
      INFO: Job: [FlowJob: [name=job1]] completed with the following parameters: [{currTime=1240413800014}] and the following status: [COMPLETED]

      The HelloWorld print only one time on my screen... I need to call each time my writer... how to do?

      Thank you very much

      Comment


      • #4
        I don't think it's possible to say without seeing some more details of your job configuration and/or implementation.

        Please use [CODE][/CODE] tags for code and stack traces.

        Comment

        Working...
        X