Spring Batch-自定义FileItemWriter的零星问题

时间:2019-03-05 14:18:20

标签: spring

我们有多个作业在并行运行的Linux环境中运行。我们在这些批处理中的每批中处理带有数十万条记录的文件。以下是我们的工作steps.xml。该作业每天运行,但偶尔会失败。它运行95%的时间没有任何问题,但是如果失败,它将失败并显示以下错误。有人可以检查我们的配置出了什么问题,并告诉解决方法吗?

Error:
"org.springframework.batch.item.ItemStreamException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.com.xxx.xx.batchsync.BatchsyncExtractFileItemWriter': Initialization of bean failed; nested exception is java.lang.IllegalStateException: **Not allowed to access field 'outputFile2': java.lang.IllegalAccessException: Class org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor$1 can not access a member of class com.xxx.xx.std.StdFileItemWriter with modifiers "private"**
              at org.springframework.batch.jsr.item.CheckpointSupport.open(CheckpointSupport.java:65)
              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.jsr.job.flow.support.state.JsrStepState.handle(JsrStepState.java:53)
              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.jsr.job.flow.JsrFlowJob.doExecute(JsrFlowJob.java:82)
              at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
              at org.springframework.batch.core.jsr.launch.JsrJobOperator$2.run(JsrJobOperator.java:675)
              at java.lang.Thread.run(Thread.java:809)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.com.xxx.xx.batchsync.BatchsyncExtractFileItemWriter': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Not allowed to access field 'outputFile2': java.lang.IllegalAccessException: Class org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor$1 can not access a member of class com.xxx.xx.std.StdFileItemWriter with modifiers "private"
              at org.springframework.beans.factory.support.AbstractAutowireCapa"

Steps.xml:

enter code here
<step id="#{jobParameters['STEPNAME']}-Step1">
    <properties>
        <property name="JOB_FILE_NAME" value="BatchsyncExtract"/>
        <property name="JOBNAME" value="#{jobParameters['JOBNAME']}"/>
        <property name="STEPNAME" value="#{jobParameters['STEPNAME']}"/>
        <property name="APPL" value="#{jobParameters['APPL']}"/>
        <property name="BANK" value="#{jobParameters['BANK']}"/>
        <property name="ODATE" value="#{jobParameters['ODATE']}"/>
        <property name="PREVENT_JOB_RESTART" value="#{jobParameters['PREVENT_JOB_RESTART']}"/>
        <property name="BATCH_ROOT" value="#{jobParameters['BATCH_ROOT']}"/>
        <property name="WSBATCH_HOME" value="#{jobParameters['WSBATCH_HOME']}"/>
        <property name="BATCH_LOG_FOLDER" value="#{jobParameters['BATCH_ROOT']}/batch/logs"/>
        <property name="BUSINESS_MAIN" value="com.xxx.xx.BatchsyncExtractBusinessmain"/>
        <property name="PROGRAM_NAME" value="IV-IpBatchsyncExtract"/>
        <property name="TODAY" value="#{jobParameters['TODAY']}"/>
        ....    
        <property name="PARTITION" value="#{jobParameters['WSBATCH_HOME']}/partinfo/BatchsyncExtract_LdbidIpIdPartition_#{jobParameters['BANK']}.xml"/>
        <property name="CHUNKSIZE" value="#{jobParameters['CHUNKSIZE']}" />
    </properties>

    <listeners>
        <listener ref="com.xxx.xx.std.StdStepListener">
        </listener>
         <listener ref="com.xxx.xx.std.StdChunkListener">
        </listener>
    </listeners>

    <chunk checkpoint-policy="custom" >
        <reader ref="com.xxx.xx.BatchsyncExtractInputBDS">
        </reader>
        <processor ref="com.xxx.xx.std.StdJobStepCursorBased"/>
         <writer ref="com.xxx.xx.BatchsyncExtractFileItemWriter">
            <properties>
                <property name="outputFile1" value="#{jobParameters['BATCH_ROOT']}/batch/import/#{jobParameters['APPL']}/batchsync_extract_#{jobParameters['BANK']}_#{jobParameters['ODATE']}_#{jobParameters['RUN']};default;default" />
                <property name="outputFile2" value="#{jobParameters['BATCH_ROOT']}/batch/import/#{jobParameters['APPL']}/batchsync_extract_totals_#{jobParameters['BANK']}_#{jobParameters['ODATE']}_#{jobParameters['RUN']};default;default" />
            </properties>
        </writer> 
        <checkpoint-algorithm ref="com.xxx.xx.batch.utils.CustomCheckPointAlgoritmn">
            <properties>
                <property name="chunkSize" value="#{jobParameters['CHUNKSIZE']}" />
                <!--property name="timeInterval" value="#{jobParameters['TIMEINTERVAL']}" /-->
            </properties>
        </checkpoint-algorithm>
    </chunk>
</step>

0 个答案:

没有答案