有时候,当我的批处理正在运行时,尝试使用这个简单的代码获取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:创建名为&#39; scopedTarget.stepCheck&#39;的bean时出错。在类路径中定义 resource [StampeBatchDataLayer.xml]:bean的初始化失败; 嵌套异常是 org.springframework.beans.factory.BeanExpressionException:Expression 解析失败;嵌套异常是 org.springframework.expression.spel.SpelEvaluationException: EL1029E:(pos 55):尝试执行方法时出现问题 &#39; checkParametro&#39;关于#java; java.lang.Class&#39;:&#39;问题的对象 调用方法:public static java.lang.String com.arca.stampebatch.datalayer.cache.CheckParametri.checkParametro(java.util.List中,java.lang.String中) 抛出com.arca.danni.utils.exception.SpringBatchStopException&#39; 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 在org.springframework.beans.factory.support.AbstractBeanFactory $ 2.getObject(AbstractBeanFactory.java:332) 在org.springframework.batch.core.scope.StepScope.get(StepScope.java:150) 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328) 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 在org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) 在org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182) 在$ Proxy0.execute(未知来源) 在org.springframework.batch.core.step.tasklet.TaskletStep $ ChunkTransactionCallback.doInTransaction(TaskletStep.java:386) 在org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) 在org.springframework.batch.core.step.tasklet.TaskletStep $ 2.doInChunkContext(TaskletStep.java:264) 在org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76) 在org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367) 在org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214) 在org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) 在org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250) 在org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195) 在org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135) 在org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61) 在org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) 在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) 在org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281) 在org.springframework.batch.core.launch.support.SimpleJobLauncher $ 1.run(SimpleJobLauncher.java:120) 在org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48) 在org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114) 在org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:349) 在org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574) 引起:org.springframework.beans.factory.BeanExpressionException:Expression 解析失败;嵌套异常是 org.springframework.expression.spel.SpelEvaluationException: EL1029E:(pos 55):尝试执行方法时出现问题 &#39; checkParametro&#39;关于#java; java.lang.Class&#39;:&#39;问题的对象 调用方法:public static java.lang.String com.arca.stampebatch.datalayer.cache.CheckParametri.checkParametro(java.util.List中,java.lang.String中) 抛出com.arca.danni.utils.exception.SpringBatchStopException&#39; 在org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142) 在org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299) 在org.springframework.beans.factory.support.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个 引起:org.springframework.expression.spel.SpelEvaluationException: EL1029E:(pos 55):尝试执行方法时出现问题 &#39; checkParametro&#39;关于#java; java.lang.Class&#39;:&#39;问题的对象 调用方法:public static java.lang.String com.arca.stampebatch.datalayer.cache.CheckParametri.checkParametro(java.util.List中,java.lang.String中) 抛出com.arca.danni.utils.exception.SpringBatchStopException&#39; 在org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:114) 在org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57) 在org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) 在org.springframework.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中) 抛出com.arca.danni.utils.exception.SpringBatchStopException 在org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:73) 在org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:109) ......还有39个 引起:org.springframework.beans.factory.BeanExpressionException:Expression 解析失败;嵌套异常是 org.springframework.beans.NotReadablePropertyException:无效 property&#39; jobParameters&#39;豆类 [org.springframework.batch.core.scope.context.StepContext]:Bean property&#39; jobParameters&#39;无法读取或具有无效的getter method:getter的返回类型是否与参数类型匹配 二传手? 在org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142) 在org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299) 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:210) 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:182) at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630) 在org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 在org.springframework.beans.factory.support.AbstractBeanFactory $ 2.getObject(AbstractBeanFactory.java:332) 在org.springframework.batch.core.scope.StepScope.get(StepScope.java:150) 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328) 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 在org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) 在org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182) 在$ Proxy19.toString(未知来源) 在org.springframework.util.ObjectUtils.nullSafeToString(ObjectUtils.java:610) 在org.springframework.core.convert.ConversionFailedException。(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.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:61) ......还有40多个 引起:org.springframework.beans.NotReadablePropertyException:无效的属性&#39; jobParameters&#39;豆类 [org.springframework.batch.core.scope.context.StepContext]:Bean property&#39; jobParameters&#39;无法读取或具有无效的getter method:getter的返回类型是否与参数类型匹配 二传手? 在org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:729) 在org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:721) 在org.springframework.batch.core.scope.StepScope.resolveContextualObject(StepScope.java:131) 在org.springframework.beans.factory.config.BeanExpressionContext.containsObject(BeanExpressionContext.java:51) at org.springframework.context.expression.BeanExpressionContextAccessor.canRead(BeanExpressionContextAccessor.java:36) 在org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:190) 在org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72) 在org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52) 在org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) 在org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:88) at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139) ... 63更多
当抛出异常时,我尝试重新启动批处理,结果没问题。
为什么,在第二次运行并且在第一次运行之后,是否会抛出异常?
我使用的是Spring Batch 2.1.8.RELEASE和IBM JDK 1.7
我该如何解决这个问题? 感谢。