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

  • Problem Injecting value into MultiItemResourceReader

    Hi,

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

    I'm getting this error :

    Code:
    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,java.io.Serializable,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [xxx.xxx.itemReaders.CustomeMultiResourceReader] for property 'resource': no matching editors or conversion strategy found
    	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
    	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
    here is my xml config

    Code:
    <batch:step id="decompress" next="readWriteUnmatched">
    <batch:tasklet ref="decompressTasklet" />
    </batch:step>
    <batch:step id="readWriteUnmatched" next="readWriteMatched">
    			<batch:tasklet>
    				<batch:chunk reader="multiResourcesReaderUn" processor="unmatchedProcessor" writer="unmatchedWriter" commit-interval="1" skip-limit="99999">
    					<batch:skippable-exception-classes>
    						<batch:include class="java.lang.Exception"/>
    					</batch:skippable-exception-classes>
    				</batch:chunk>
    			</batch:tasklet>
    			<batch:listeners>
    				<batch:listener ref="unmatchedSkipListener"/>
    				<batch:listener ref="unmatchedFileChangeListener"/>
    			</batch:listeners>
    </batch:step>
    
    <bean id="decompressTasklet" class="xxx.xxx.DecompressTasklet" scope="step">
    		<property name="inputResource" value="file:///#{jobParameters['inputResource']}" />
    		<property name="targetDirectory" value="#{jobParameters['targetDirectory']}" />
    </bean>
    
    <bean id="multiResourcesReaderUn" class="xxx.xxx.itemReaders.CustomeMultiResourceReader" 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"/>
    </bean>
    It works perfectly fine for the decompressTasklet but not for the multiResourceReaderUn.

    Any help would be appreciated.
    Last edited by fruitloop; Mar 23rd, 2012, 03: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)

    Comment


    • #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 ?

      Comment


      • #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, 07:10 AM.

        Comment

        Working...
        X