bean类的无效属性'jobParameters' StepContext:Bean属性'jobParameters'不可读或具有无效的getter方法

有时,当我的批处理正在运行时,尝试使用这个简单的代码获得 JobParameters

<bean id="codiceParametroMaxDurataJob" class="java.lang.String"
    scope="step">
    <constructor-arg
        value="#{jobParameters['job'].concat('_DURATA_MASSIMA_ESECUZIONE')}">
    </constructor-arg>
</bean>

我得到以下异常

遇到执行步骤org.springframework.beans.factory.BeanCreationException的错误:创建类路径资源[StampeBatchDataLayer.xml]中定义的名为'scopedTarget.stepCheck'的bean时出错:bean的初始化失败;嵌套异常是org.springframework.beans.factory.BeanExpressionException:表达式解析失败;嵌套异常是org.springframework.expression.spel.SpelEvaluationException:EL1029E:(pos 55):尝试在'java.lang.Class'类型的对象上执行方法'checkParametro'时出现问题:'问题调用方法:public static java.lang.String com.arca.stampebatch.datalayer.cache.CheckParametri.checkParametro(java.util.List,java.lang.String)在org.springframework.beans处抛出com.arca.danni.utils.exception.SpringBatchStopException' .factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)位于org.springframework.beans.factory.support.AbstractBeanFactory $ 2的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) . org.springframework.batch.core.scope.StepScope.get(StepScope.java:150)中的getObject(AbstractBeanFactory.java:332)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)在org.springfram ework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)位于org.springframework.aop.framework.JdkDynamicAopProxy.invoke的org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) JdkDynamicAopProxy.java:182)atg.springframework.batch.core.step.tasklet.TaskletStep $ ChunkTransactionCallback.doInTransaction(TaskletStep.java:386)位于org.springframework.transaction.support.TransactionTemplate的$ Proxy0.execute(未知来源) .execute(TransactionTemplate.java:130)org.springframework.batch.core.step.tasklet.TaskletStep $ 2.doInChunkContext(TaskletStep.java:264)org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(在Org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)的org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)org中的StepContextRepeatCallback.java:76) .springframework.batch.repeat.support . 在org.springframework.batch.core.step.AbstractStep.execute(AbstractStep . )的org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250)上的RepeatTemplate.iterate(RepeatTemplate.java:143) . java:195)org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)at org .springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)at org .springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)位于org.springframework.core的org.springframework.batch.core.launch.support.SimpleJobLauncher $ 1.run(SimpleJobLauncher.java:120) . task.SyncTaskExecutor.execu te(SyncTaskExecutor.java:48)org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner . java:349)at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)引起:org.springframework.beans.factory.BeanExpressionException:表达式解析失败;嵌套异常是org.springframework.expression.spel.SpelEvaluationException:EL1029E:(pos 55):尝试在'java.lang.Class'类型的对象上执行方法'checkParametro'时出现问题:'问题调用方法:public static java.lang.String com.arca.stampebatch.datalayer.cache.CheckParametri.checkParametro(java.util.List,java.lang.String)抛出com.arca.danni.utils.exception.SpringBatchStopException'at atorg.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142)位于org.springframework.beans.factory.support的org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299) . BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:210)在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:182)在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java: 1360)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)... 29更多原因by:org.springframework.expression.spel.SpelEvaluationExce ption:EL1029E:(pos 55):尝试在'java.lang.Class'类型的对象上执行方法'checkParametro'时出现问题:'问题调用方法:public static java.lang.String com.arca.stampebatch . datalayer.cache.CheckParametri.checkParametro(java.util.List,java.lang.String)在org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference . )中抛出com.arca.danni.utils.exception.SpringBatchStopException' . java:114)org.springframework上的org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) .expression.spel.standard.SpelExpression.getValue(SpelExpression.java:88)at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139)... 35更多引起:org.springframework.expression . AccessException:问题调用方法:public static java.lang.String com.arca . stampebatch.datalayer.cache.CheckParametri.checkParametro(java.util.List,java.lang.String)在org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute抛出com.arca.danni.utils.exception.SpringBatchStopException(ReflectiveMethodExecutor) .java:73)at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:109)... 39更多引起:org.springframework.beans.factory.BeanExpressionException:表达式解析失败;嵌套异常是org.springframework.beans.NotReadablePropertyException:bean类的无效属性'jobParameters'[org.springframework.batch.core.scope.context.StepContext]:Bean属性'jobParameters'不可读或具有无效的getter方法: getter的返回类型是否与setter的参数类型匹配? org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142)org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299)org.springframework.beans.factory.support位于org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java)的org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:182)中的.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:210) :630)org.springframework上的org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035) . beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowi reCapableBeanFactory.java:939)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)at org .springframework.beans.factory.support.AbstractBeanFactory $ 2.getObject(AbstractBeanFactory.java:332)位于org.springframework.beans.factory的org.springframework.batch.core.scope.StepScope.get(StepScope.java:150) . support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)at atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)位于org.springframework.aop.frame.JdkDynamicAopProxy的org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) . 在org.springframework.core.convert.ConversionFailedException调用(JdkDynamicAopProxy.java:182)在$ Proxy19.toString(来源不明)在org.springframework.util.ObjectUtils.nullSafeToString(ObjectUtils.java:610)(ConversionFailedException.java: 46)在org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)在org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:171)在org.springframework.expression .spel.support.StandardTypeConverter.convertValue(StandardTypeConverter.java:66)在org.springframework.expression.spel.support.ReflectionHelper.convertArguments(ReflectionHelper.java:281)在org.springframework.expression.spel.support.ReflectiveMeth org.springframework.beans.NotReadablePropertyException:odExecutor.execute(ReflectiveMethodExecutor.java:61)... 40更致bean类的无效的属性 'jobParameters'[org.springframework.batch.core.scope.context.StepContext]: Bean属性'jobParameters'不可读或具有无效的getter方法:getter的返回类型是否与setter的参数类型匹配? org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:729)org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:721)at org.springframework.batch.core.scope.StepScope.resolveContextualObject(StepScope)的.java:131)在org.springframework.beans.factory.config.BeanExpressionContext.containsObject(BeanExpressionContext.java:51)在org.springframework.context.expression.BeanExpressionContextAccessor.canRead(BeanExpressionContextAccessor.java:36)在org.springframework . expression.spel.ast.PropertyOrFieldReference.readProperty在org.springframework.expression.spel.ast.CompoundExpression(PropertyOrFieldReference.java:190)在org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72) . getgalueInternal(CompoundExpression.java:52)org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)org.springframework.expression.spel.standard.SpelExpression.getValu e(SpelExpression.java:88)org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139)... 63更多

抛出异常时,我尝试重新启动批处理,结果正常 .

为什么,在第二次运行和紧接第一次运行之后,是否会抛出异常?

我正在使用Spring Batch 2.1.8.RELEASE和IBM JDK 1.7

我该如何解决这个问题?谢谢 .

回答(0)