Announcement Announcement Module
Collapse
No announcement yet.
Wierd system error - Spring Batch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wierd system error - Spring Batch

    Hello All,

    I do not have any clue on this error, can someone help me to understand this issue:

    I have composite reader (implements ItemReader) which actually reads from two file readers. I made the scope of this composite reader and other readers to step (scope="step"). Then I got the following error when it tries to initialize this step:

    Code:
    1:14:00,110 ERROR main AbstractStep:213 - Encountered an error executing the step: class org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lazyBindingProxy.compositeContractReader#sysinit' defined in class path resource [jobs/ReportJob.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type [$Proxy4 implementing org.springframework.batch.item.file.ResourceAwareItemReaderItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemReader]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy4 implementing org.springframework.batch.item.file.ResourceAwareItemReaderItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemReader]: no matching editors or conversion strategy found
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lazyBindingProxy.compositeContractReader#sysinit' defined in class path resource [jobs/ReportJob.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type [$Proxy4 implementing org.springframework.batch.item.file.ResourceAwareItemReaderItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemReader]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy4 implementing org.springframework.batch.item.file.ResourceAwareItemReaderItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemReader]: no matching editors or conversion strategy found
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.batch.core.scope.StepScope.get(StepScope.java:120)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.batch.core.scope.util.PlaceholderTargetSource.getTarget(PlaceholderTargetSource.java:205)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184)
    	at $Proxy2.read(Unknown Source)
    	at org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:90)
    	at org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:127)
    	at org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:106)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:103)
    	at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:64)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
    	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197)
    	at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348)
    	at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
    	at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137)
    	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)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
    	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:105)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:250)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:110)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:105)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:207)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:254)
    Caused by: org.springframework.beans.TypeMismatchException: Failed to convert value of type [$Proxy4 implementing org.springframework.batch.item.file.ResourceAwareItemReaderItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemReader]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy4 implementing org.springframework.batch.item.file.ResourceAwareItemReaderItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemReader]: no matching editors or conversion strategy found
    	at org.springframework.beans.SimpleTypeConverter.convertIfNecessary(SimpleTypeConverter.java:50)
    	at org.springframework.batch.core.scope.util.PlaceholderTargetSource$1.convertIfNecessary(PlaceholderTargetSource.java:146)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1294)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    	... 39 more
    Is there anything specific I have to do here for Spring Batch 2.0?

    Thanks in advance!

    Just to add an additional comment, this step works just fine if I remove the scope="step" from the declaration. But I am late binding a parameter which requires me to have this defined as scope="step". So I am kind of got in a limbo!! :-(
    Last edited by hailspring; Jun 26th, 2009, 11:30 AM.

  • #2
    You are injecting the step-scoped bean, but the setter you are using has the implementation type and not the interface type.

    Comment


    • #3
      Code:
      <beans:bean id="compositeReader" class="com.batch.reader.CompositeReader" scope="step">
        <beans:property name="fileReader1" ref="fileReader1" />
        <beans:property name="fileReader2" ref="fileReader2" />
      </beans:bean>
      In the above code, CompositeReader implements ItemReader
      fileReader1 and fileReader2 are declared as "FlatFileItemReader" in configuration file
      and were set to compositeReader's property which have them defined as ItemReader (I also
      tried having them declared as "FlatFileItemReader".

      Both the fileReader1 and fileReader2 were set to scope="step".

      Can you please elaborate your response and what should I do differently.

      Comment


      • #4
        Garrette, ignore my comment before!! There were couple of other steps written by another developer which I had to change. And YES you were correct about the issue, and were right to the point!!
        Thanks a lot once again!!

        Comment

        Working...
        X