spring - Error creating bean with name 'scopedTarget.org.springframework.batch.repeat.policy.SimpleCompletionPolicy#0' -
i'm using spring boot version 1.4.2.release , sprig batch framework. i'm trying import data files , after storing results in database, i'm dealing dynamic commit interval number implemented method returns number of lines of input file , passing parameter using "jobparameters":
my batch job configuration looks this:
<beans:bean id="stepscope" class="org.springframework.batch.core.scope.stepscope"> <beans:property name="autoproxy" value="true"/> </beans:bean> <beans:bean id="myprocessor" class="org.job.step.myprocessor" scope="step" /> <beans:bean id="mywriter" class="org.job.step.mywriter" scope="step" /> <beans:bean id="jobcompletenotificationlistener" class="org.job.jobcompletionnotificationlistener" /> <job id="myimportjob"> <step id="step1"> <tasklet transaction-manager="transactionmanager"> <chunk reader="myreader" processor="myprocessor" writer="mywriter" commit-interval="#{jobparameters['commit.interval']}" > </chunk> </tasklet> </step> <listeners> <listener ref="jobcompletenotificationlistener" /> </listeners> </job> <beans:bean id="headerbaseddelimitedlinetokenizer" scope="step" class="org.job.custom.headerbaseddelimitedlinetokenizer"> <beans:property name="delimiter" value=";" /> </beans:bean> <!-- <beans:bean id="customlinetokenizer" class="org.job.step.customlinetokenizer"/> --> <beans:bean id="myreader" scope="step" class="org.springframework.batch.item.file.flatfileitemreader"> <beans:property name="resource" value="file:/#{jobparameters['input.file.name']}" /> <beans:property name="encoding" value="utf-8" /> <beans:property name="strict" value="false" /> <beans:property name="linestoskip" value="1" /> <beans:property name="skippedlinescallback"> <beans:ref bean="headerbaseddelimitedlinetokenizer" /> </beans:property> <beans:property name="linemapper"> <beans:bean class="org.springframework.batch.item.file.mapping.defaultlinemapper"> <beans:property name="linetokenizer"> <beans:ref bean="headerbaseddelimitedlinetokenizer" /> </beans:property> <beans:property name="fieldsetmapper"> <beans:bean class="org.job.step.myfieldsetmapper" /> </beans:property> </beans:bean> </beans:property> </beans:bean>
it throws exception given bellow when first running spring boot application:
2017-04-07 15:03:04.537 -error [pid=8692] org.springframework.batch.core.step.abstractstep.execute : encountered error executing step step1 in job myimportjob org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'scopedtarget.org.springframework.batch.repeat.policy.simplecompletionpolicy#0': unsatisfied dependency expressed through constructor parameter 0: not convert argument value of type [null] required type [int]: failed convert value of type 'null' required type 'int'; nested exception java.lang.illegalargumentexception: cannot convert value of type 'null' required type 'int': propertyeditor [org.springframework.beans.propertyeditors.customnumbereditor] returned inappropriate value of type 'null' @ org.springframework.beans.factory.support.constructorresolver.createargumentarray(constructorresolver.java:723) @ org.springframework.beans.factory.support.constructorresolver.autowireconstructor(constructorresolver.java:189) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.autowireconstructor(abstractautowirecapablebeanfactory.java:1148) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:1050) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:512) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:482) @ org.springframework.beans.factory.support.abstractbeanfactory$2.getobject(abstractbeanfactory.java:345) @ org.springframework.batch.core.scope.stepscope.get(stepscope.java:113) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:340) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:197) @ org.springframework.aop.target.simplebeantargetsource.gettarget(simplebeantargetsource.java:35) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:192) @ com.sun.proxy.$proxy50.start(unknown source) @ org.springframework.batch.repeat.support.repeattemplate.start(repeattemplate.java:468) @ org.springframework.batch.repeat.support.repeattemplate.executeinternal(repeattemplate.java:169) @ org.springframework.batch.repeat.support.repeattemplate.iterate(repeattemplate.java:144) @ org.springframework.batch.core.step.item.simplechunkprovider.provide(simplechunkprovider.java:110) @ org.springframework.batch.core.step.item.chunkorientedtasklet.execute(chunkorientedtasklet.java:69) @ org.springframework.batch.core.step.tasklet.taskletstep$chunktransactioncallback.dointransaction(taskletstep.java:406) @ org.springframework.batch.core.step.tasklet.taskletstep$chunktransactioncallback.dointransaction(taskletstep.java:330) @ org.springframework.transaction.support.transactiontemplate.execute(transactiontemplate.java:133) @ org.springframework.batch.core.step.tasklet.taskletstep$2.doinchunkcontext(taskletstep.java:271) @ org.springframework.batch.core.scope.context.stepcontextrepeatcallback.doiniteration(stepcontextrepeatcallback.java:81) @ org.springframework.batch.repeat.support.repeattemplate.getnextresult(repeattemplate.java:374) @ org.springframework.batch.repeat.support.repeattemplate.executeinternal(repeattemplate.java:215) @ org.springframework.batch.repeat.support.repeattemplate.iterate(repeattemplate.java:144) @ org.springframework.batch.core.step.tasklet.taskletstep.doexecute(taskletstep.java:257) @ org.springframework.batch.core.step.abstractstep.execute(abstractstep.java:200) @ org.springframework.batch.core.job.simplestephandler.handlestep(simplestephandler.java:148) @ org.springframework.batch.core.job.flow.jobflowexecutor.executestep(jobflowexecutor.java:64) @ org.springframework.batch.core.job.flow.support.state.stepstate.handle(stepstate.java:67) @ org.springframework.batch.core.job.flow.support.simpleflow.resume(simpleflow.java:169) @ org.springframework.batch.core.job.flow.support.simpleflow.start(simpleflow.java:144) @ org.springframework.batch.core.job.flow.flowjob.doexecute(flowjob.java:134) @ org.springframework.batch.core.job.abstractjob.execute(abstractjob.java:306) @ org.springframework.batch.core.launch.support.simplejoblauncher$1.run(simplejoblauncher.java:135) @ org.springframework.core.task.synctaskexecutor.execute(synctaskexecutor.java:50) @ org.springframework.batch.core.launch.support.simplejoblauncher.run(simplejoblauncher.java:128) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:333) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) @ org.springframework.batch.core.configuration.annotation.simplebatchconfiguration$passthruadvice.invoke(simplebatchconfiguration.java:127) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:213) @ com.sun.proxy.$proxy75.run(unknown source) @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.execute(joblaunchercommandlinerunner.java:216) @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.executelocaljobs(joblaunchercommandlinerunner.java:233) @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.launchjobfromproperties(joblaunchercommandlinerunner.java:125) @ org.springframework.boot.autoconfigure.batch.joblaunchercommandlinerunner.run(joblaunchercommandlinerunner.java:119) @ org.springframework.boot.springapplication.callrunner(springapplication.java:800) @ org.springframework.boot.springapplication.callrunners(springapplication.java:784) @ org.springframework.boot.springapplication.afterrefresh(springapplication.java:771) @ org.springframework.boot.springapplication.run(springapplication.java:316) @ org.springframework.boot.springapplication.run(springapplication.java:1186) @ org.springframework.boot.springapplication.run(springapplication.java:1175)
spring tries inject constructor-arg of type int, value null.
null cannot converted int, thats why face exception.
from description guess, spring expression
#{jobparameters['commit.interval']}
results in null.
use debugger see, value injected bean 'transactionmanager'
Comments
Post a Comment