Announcement Announcement Module
Collapse
No announcement yet.
java.lang.IllegalArgumentException: ExecutionId must not be null Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.IllegalArgumentException: ExecutionId must not be null

    I upgraded to Spring Batch 1.1.0 and ran a test that throws a runtime exception in my item writer. I can't see why this would be happening now..


    12:36:42.261 [main] ERROR org.springframework.batch.core.step.AbstractStep - Encountered an error on listener error callback.
    java.lang.IllegalArgumentException: ExecutionId must not be null.
    at org.springframework.util.Assert.notNull(Assert.jav a:112)
    at org.springframework.batch.core.repository.dao.Jdbc ExecutionContextDao.saveOrUpdateExecutionContext(J dbcExecutionContextDao.java:105)

  • #2
    Looks like at the id of job or step execution is null (execution is not saved) when the associated execution context is being saved.

    Can you post the whole stacktrace?

    Comment


    • #3
      Here's the traces. I hope this helps.
      I am executing a job where step #1 copies a directory of "pending" files from a remote location (usually 1-3 files). Then step #2 iterates the file list, and for each file, synchonously executes a job to process a file.
      I did it this way because I thought it might be easier to deal with failed files as their own failed jobs.

      --Michael

      This is the trace caused by me intentionally throwing an exception in the middle of a stream of item processing:
      08:50:02.362 [main] INFO org.springframework.batch.core.launch.support.Simp leJobLauncher - Job: [SimpleJob: [name=paymentMethodSingleFileProcessorJob]] failed wi
      th the following parameters: [{jobExecutionDirectoryName=07242008-084959-565, jobFileName=file:///private/tmp/batchTest/working/07242008-084959-565/0000826693.0805
      22.MAU}{}{}{}]
      ecsRefId-138-1216914602171-1:com.real.ecs.batch.jobs.visaupdater.PWSFailureMo ckException: Mock test failure
      at org.easymock.internal.MockInvocationHandler.invoke (MockInvocationHandler.java:34)
      at org.easymock.internal.ObjectMethodsFilter.invoke(O bjectMethodsFilter.java:61)
      at $Proxy12.updatePaymentMethod(Unknown Source)
      at com.real.ecs.batch.jobs.visaupdater.PaymentMethodU pdaterItemWriter.write(PaymentMethodUpdaterItemWri ter.java:37)
      at org.springframework.batch.item.support.DelegatingI temWriter.write(DelegatingItemWriter.java:45)
      at org.springframework.batch.core.step.item.BatchList enerFactoryHelper$2.write(BatchListenerFactoryHelp er.java:99)
      at org.springframework.batch.core.step.item.SimpleIte mHandler.doWrite(SimpleItemHandler.java:105)
      at org.springframework.batch.core.step.item.SimpleIte mHandler.write(SimpleItemHandler.java:97)
      at org.springframework.batch.core.step.item.SimpleIte mHandler.handle(SimpleItemHandler.java:71)
      at org.springframework.batch.core.step.item.ItemOrien tedStep$2.doInIteration(ItemOrientedStep.java:368)
      at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:346)
      at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:212)
      at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
      at org.springframework.batch.core.step.item.ItemOrien tedStep.processChunk(ItemOrientedStep.java:361)
      at org.springframework.batch.core.step.item.ItemOrien tedStep$1.doInIteration(ItemOrientedStep.java:249)
      at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:346)
      at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:212)
      at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
      at org.springframework.batch.core.step.item.ItemOrien tedStep.doExecute(ItemOrientedStep.java:231)
      at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:170)
      at org.springframework.batch.core.job.SimpleJob.execu te(SimpleJob.java:100)
      at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:86)
      at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
      at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:81)
      at com.real.ecs.batch.jobs.visaupdater.FileProcessorT ask.execute(FileProcessorTask.java:84)
      at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:98)
      at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:170)
      at org.springframework.batch.core.job.SimpleJob.execu te(SimpleJob.java:100)
      at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:86)
      at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
      at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:81)
      at com.real.ecs.batch.jobs.visaupdater.PendingFileLoc alFileProcessorTest.testSuccessfulBatchRetryOnPwsF ailure(PendingFileLocalFileProcessorTest.java:155)


      Here is the exception thrown when the IllegalArgumentException occurs:

      08:50:02.363 [main] ERROR org.springframework.batch.core.step.AbstractStep - Encountered an error executing the step: class com.real.ecs.batch.jobs.visaupdater.PW
      SFailureMockException: Mock test failure
      08:50:02.383 [main] ERROR org.springframework.batch.core.step.AbstractStep - Encountered an error on listener error callback.
      java.lang.IllegalArgumentException: ExecutionId must not be null.
      at org.springframework.util.Assert.notNull(Assert.jav a:112)
      at org.springframework.batch.core.repository.dao.Jdbc ExecutionContextDao.saveOrUpdateExecutionContext(J dbcExecutionContextDao.java:105)
      at org.springframework.batch.core.repository.dao.Jdbc StepExecutionDao.saveOrUpdateExecutionContext(Jdbc StepExecutionDao.java:142)
      at org.springframework.batch.core.repository.support. SimpleJobRepository.saveOrUpdateExecutionContext(S impleJobRepository.java:254)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknow n Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:310)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
      at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
      at $Proxy9.saveOrUpdateExecutionContext(Unknown Source)
      at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:199)
      at org.springframework.batch.core.job.SimpleJob.execu te(SimpleJob.java:100)
      at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:86)
      at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
      at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:81)
      at com.real.ecs.batch.jobs.visaupdater.PendingFileLoc alFileProcessorTest.testSuccessfulBatchRetryOnPwsF ailure(PendingFileLocalFileProcessorTest.java:155)

      Comment


      • #4
        Originally posted by moores View Post
        Then step #2 iterates the file list, and for each file, synchonously executes a job to process a file.
        Can you explain this statement? Are you literally kicking off one spring batch job from within another?

        Comment


        • #5
          Yes, that is right.
          I am using a JobLauncher to launch a job from within another job.

          Comment


          • #6
            I would say that's definitely you're problem...Spring Batch wasn't really designed to allow this behavior. What's probably tripping it up the most is the transaction semantics of the nested step. I've had the same requirement before at a client, and I did use the same approach to wrap a JobLauncher to launch multiple jobs, which is fine, but not within another job. If you need the other step to happen beforehand, I would put it into a separate job and schedule it to run before.

            Comment


            • #7
              I don't see why it shouldn't work as long as the new job is not launched from within a transaction. You can use a TaskletStep for that, or set the TransactionAttributes in a normal step so that the propagation is Propagation.NEVER. I haven't tried it myself, so I'd be interested to know if that was the problem.

              Comment


              • #8
                Originally posted by lucasward View Post
                I would say that's definitely you're problem...Spring Batch wasn't really designed to allow this behavior.
                If that is not allowed by design, then there should be an exception thrown to indicate we can't launch a job from within a job. I think there's a bug in Spring Batch if all I see is an IllegalArgumentException.

                This feels like a very natural way to solve a problem with delegation.
                My outer job is iterating through a list of things to do, and it delegates to jobs that know how to solve the problem.
                So I am kinda screwed here? Why can't transactions be isolated here?
                (If that is the root cause of this IllegalArguementException)

                I am also looking at designing a job that will figure out how to partition some work across several dozen jobs executed asynchronously. I know there is lots of architectural work going on to make this a first class abstraction (via help from Spring Integration?) , but for now I really need to be able to partition work by a job execution.

                Since my problem at hand now is pretty simple, iterating through a few file names (files use the same reader logic) and delegating a job for each one of them, I thought it might be possible to use a SortedMultiResourceItemReader. But in my case I'd like to address the specific file problems by re-launching a failed job.

                Comment


                • #9
                  Yep; that is what i'm doing here.
                  My "fileProcessorTask" is the one that delegates to an injected JobLauncher.

                  What do you recommend as an alternative design?

                  Code:
                  <bean id="paymentMethodUpdaterFileProcessorJob" parent="simpleJob">
                  	    <description>
                  	        Processes all pending payment method updater batch files.
                  	        
                  	        First step performs file retrieval from remote source, placing pending files into
                  	        a work directory with a unique name.  Remote source files are renamed with ".OLD" extension after successful retrieval.
                  	        
                  	        Second step processes each file in the local work directory, simply delegating
                  	        to a job that can process one file.  Delegation is synchronous (although it can be 
                  	        switch to an asynchronous mode).
                  	    </description>
                  	    <property name="steps">
                  			<list>
                  			    <bean id="fileRetriever" parent="taskletStep">
                  			        <property name="tasklet" ref="fileRetrieverTask"/>
                  			    </bean>
                  			    <bean id="fileProcessor" parent="taskletStep">
                  			        <property name="tasklet" ref="fileProcessorTask"/>
                  			    </bean>
                  			</list>
                  	    </property>
                  	</bean>
                  Code:
                  <bean id="fileProcessorTask" class="com.real.ecs.batch.jobs.visaupdater.FileProcessorTask">
                  	    <description>
                  	        Processes a set of batch files located in a specified local file system directory.
                  	        Iterates file list and delegates processing of each file to the 
                  	        'paymentMethodSingleFileProcessorJob'.   
                  	    </description>
                  		<property name="baseWorkDirectoryPath" value="${paymentMethodUpdater.workDirectoryPath}" />
                  		<property name="jobLauncher" ref="synchronousJobLauncher" />
                  		<property name="paymentMethodUpdaterJob" ref="paymentMethodSingleFileProcessorJob" />
                  	</bean>

                  Comment


                  • #10
                    I have the same problem in case of error in a simple Tasklet.

                    When an exception is thrown during a step execution, the AbstractStep tries to save the executionContext of stepExecution (getJobRepository().saveOrUpdateExecutionContext(s tepExecution)) and checks if the identifier is not null (in JdbcExecutionContextDao.saveOrUpdateExecutionConte xt(StepExecution) ), before saving the stepExecution with JobRepository.saveOrUpdate(StepExecution stepExecution)) and creating an identifier for the stepExecution...

                    This error doesn't exist with the version 1.0.1-RELEASE of spring Batch.

                    Comment


                    • #11
                      Confirmed, this is a bug in 1.1 - saveOrUpdateExecutionContext(StepExecution) used to call saveStepExecution(StepExecution) first which has changed and created the bug.

                      http://jira.springframework.org/browse/BATCH-751

                      Comment

                      Working...
                      X