Announcement Announcement Module
No announcement yet.
Problem Injecting value into MultiItemResourceReader Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem Injecting value into MultiItemResourceReader


    I'm trying to inject the filename from jobParameters into a custom MultiItemResourceReader at step scope.

    I'm getting this error :

    Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy10 implementing 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 [] for property 'resource': no matching editors or conversion strategy found
    	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(
    	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(
    here is my xml config

    <batch:step id="decompress" next="readWriteUnmatched">
    <batch:tasklet ref="decompressTasklet" />
    <batch:step id="readWriteUnmatched" next="readWriteMatched">
    				<batch:chunk reader="multiResourcesReaderUn" processor="unmatchedProcessor" writer="unmatchedWriter" commit-interval="1" skip-limit="99999">
    						<batch:include class="java.lang.Exception"/>
    				<batch:listener ref="unmatchedSkipListener"/>
    				<batch:listener ref="unmatchedFileChangeListener"/>
    <bean id="decompressTasklet" class="" scope="step">
    		<property name="inputResource" value="file:///#{jobParameters['inputResource']}" />
    		<property name="targetDirectory" value="#{jobParameters['targetDirectory']}" />
    <bean id="multiResourcesReaderUn" class="" scope="step" >
    		<constructor-arg ref="dataSource"/>
    		<property name="archiveFile" value="#{jobParameters['inputResource']}"/>
    		<property name="resources" value="file:///C:/output/*_UNMATCHED.csv" />
    		<property name="delegate" ref="flatFileItemReaderUnmatched"/>
    It works perfectly fine for the decompressTasklet but not for the multiResourceReaderUn.

    Any help would be appreciated.
    Last edited by fruitloop; Mar 23rd, 2012, 04:59 AM.

  • #2
    Program to interfaces not concrete implementations. You are using proxies and it is a JDK proxy which acts like all the interfaces it implements NOT as the concrete class (hence the classcast exception)


    • #3
      Thanks, guess I should go and read up on proxies..

      Is there anything else I can do in the mean time to solve this problem ?


      • #4
        As I already mentioned in the previous post program to interfaces not concrete classes.

        Also it is not complaining about what you think it is complaining about, I suggest you take a look at the stacktrace again. It isn't complaining about the resource on your CustomeMultiResourceReader but you are injecting your CustomeMultiResourceReader into a bean which expects just this type insteaf of a ItemReader or ItemStreamReader,
        Last edited by Marten Deinum; Mar 23rd, 2012, 08:10 AM.