2017-07-05 5 views
0
`JdbcStepExecutionDao:275 - Truncating long message before update of StepExecution, original message is: org.springframework.batch.item.ItemStreamException: Failed to initialize the reader 
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:147) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) 
at com.sun.proxy.$Proxy21.open(Unknown Source) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) 
at com.sun.proxy.$Proxy21.open(Unknown Source) 
at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:96) 
at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:310) 
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197) 
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) 
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64) 
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67) 
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169) 
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144) 
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134) 
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306) 
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135) 
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) 
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128) 
at (...)myBaseJob.executeInternal(BaseJob.java:49) 
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75) 
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 

Causée par: java.lang.IllegalArgumentException: ressource d'entrée doit être à org.springframework.util.Assert.notNull (Assert.java:134) à org.springframework. batch.item.file.FlatFileItemReader.doOpen (FlatFileItemReader.java:245) à org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open (AbstractItemCountingItemStreamItemReader.java:144) ... 41 more`liaison tardive ne fonctionne pas avec FlatFileItemReader

I avoir deux étapes. Dans la première étape je crée un fichier et passe fichier au lecteur (comme ressource) avec le nom input_filename en utilisant le code suivant:

JobExecution jobExecution = chunkContext.getStepContext().getStepExecution().getJobExecution(); 
ExecutionContext executionContext = jobExecution.getExecutionContext(); 
String filePath = "file://" + FilenameUtils.separatorsToUnix(mydFile.getAbsolutePath()); 
executionContext.put("INPUT_FILENAME", filePath); 



<batch:job id="transformJob" job-repository="jobRepository"> 

    <batch:step id="step1" next=step2"> 
     <batch:tasklet ref="step1Tasklet" /> 
     <batch:listeners> 
      <batch:listener ref="promotionInputFileNameListener" /> 
     </batch:listeners> 
    </batch:step> 

    <batch:step id="step2"> 
     <batch:tasklet transaction-manager="imTransactionManager"> 
      <batch:chunk reader="step2Reader" writer="step2Writer" commit-interval="${step2.interval}" /> 
     </batch:tasklet> 
    </batch:step> 

<bean id="promotionInputFileNameListener" class="org.springframework.batch.core.listener.ExecutionContextPromotionListener"> 
    <property name="keys" value="INPUT_FILENAME"/> 
</bean> 

<bean id="step1Tasklet" class="com.ProduceFileTasklet" scope="step"/> 

<bean id="step2Reader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"> 
    <property name="resource" value="#{jobParameters[INPUT_FILENAME]}" /> 
    <property name="lineMapper"> 
     <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"> 
      <property name="lineTokenizer"> 
       <bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer"> 
        <property name="names" value="..." /> 
        <property name="columns" value="..." /> 
       </bean> 
      </property> 
      <property name="fieldSetMapper"> 
       <bean class="com.myClass" /> 
      </property> 
     </bean> 
    </property> 
</bean> 

Le StepContext de l'étape 2 est jamais auto rafraîchi par le promoteur .

Répondre

0

Je vois que l'étape 2 cherche le fichier d'entrée de #jobParameters, mais dans l'extrait de code, il est défini sur le contexte d'exécution pas un paramètre. Donc, à la place, il semble qu'il devrait chercher le nom du fichier dans #jobExecutionContext.