Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring批处理-自定义FileItemWriter的零星问题_Spring_Spring Batch - Fatal编程技术网

Spring批处理-自定义FileItemWriter的零星问题

Spring批处理-自定义FileItemWriter的零星问题,spring,spring-batch,Spring,Spring Batch,我们在Linux环境中运行多个作业,作业并行运行。我们处理每个批次中包含数十万条记录的文件。下面是我们的job steps.xml。此作业每天运行,但偶尔会失败。它运行了95%的时间,没有任何问题,但当它失败时,会出现以下错误。有人能检查一下我们的配置有什么问题,并告诉我们如何解决这个问题吗 Error: "org.springframework.batch.item.ItemStreamException: org.springframework.beans.factory.BeanCreat

我们在Linux环境中运行多个作业,作业并行运行。我们处理每个批次中包含数十万条记录的文件。下面是我们的job 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>
在此处输入代码
....    

您创建了具有私有属性访问权限的FileItemWriter;检查日志;您将发现由以下原因引起的
:org.springframework.beans.factory.BeanCreationException:创建名为“scopedTarget.com.xxx.xx.batchsync.BatchsyncExtractFileItemWriter”的bean时出错:bean初始化失败;嵌套异常为java.lang.IllegalStateException:不允许访问字段“outputFile2”:java.lang.IllegalAccessException:类org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor$1无法访问带有“private”修饰符的类com.xxx.xx.std.StdFileItemWriter的成员
AngeloImmediata-我正在使用BatchProperty和InjectAnnotation注入这些属性。这在95%的批处理运行中运行良好。它只是偶尔失败。因此,我认为私有财产没有任何问题。我认为问题在于多线程执行。但是不确定它是什么。很明显,异常情况是
无法访问com.xxx.xx.std.StdFileItemWriter类的成员
,因此在某些情况下,它可能试图访问
com.xxx.xx.std.StdFileItemWriter类的私有成员
我怀疑当作业以多线程模式运行时出现了问题满载。但是我很难理解到底出了什么问题你创建了一个具有私有财产访问权限的FileItemWriter;检查日志;您将发现由以下原因引起的
:org.springframework.beans.factory.BeanCreationException:创建名为“scopedTarget.com.xxx.xx.batchsync.BatchsyncExtractFileItemWriter”的bean时出错:bean初始化失败;嵌套异常为java.lang.IllegalStateException:不允许访问字段“outputFile2”:java.lang.IllegalAccessException:类org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor$1无法访问带有“private”修饰符的类com.xxx.xx.std.StdFileItemWriter的成员
AngeloImmediata-我正在使用BatchProperty和InjectAnnotation注入这些属性。这在95%的批处理运行中运行良好。它只是偶尔失败。因此,我认为私有财产没有任何问题。我认为问题在于多线程执行。但是不确定它是什么。很明显,异常情况是
无法访问com.xxx.xx.std.StdFileItemWriter类的成员
,因此在某些情况下,它可能试图访问
com.xxx.xx.std.StdFileItemWriter类的私有成员
我怀疑当作业以多线程模式运行时出现了问题满载。但我很难理解到底出了什么问题