Results 1 to 4 of 4

Thread: Multi File Input error - Spring Batch Framework

  1. #1
    Join Date
    Sep 2010
    Posts
    3

    Default Multi File Input error - Spring Batch Framework

    Hi
    I am Currently working on Spring Batch 2.0.0.RELEASE. I am trying to use the Multifile input feature that reads data from multiple files using MultiResourceItemReader. I am currently using the multiResource.xml provided in the samples folder.
    However every time I run the example I am getting thye error:
    Cannot convert value of type [org.springframework.batch.item.file.MultiResourceI temReader] to required type [org.springframework.batch.core.step.tasklet.Taskle t] for property 'tasklet': no matching editors or conversion strategy found


    Can anyone suggest some solution to the problem

  2. #2
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    looks like a simple configuration error. Can you post your XML configuration?

  3. #3
    Join Date
    Sep 2010
    Posts
    3

    Default

    hi

    the config is as follows. I have tried to get the code in the job and step format. The name of my xml is multiResourceJob.xml. I have not made only minor changes to the example code.
    Code
    Code:
    <?xml version="1.0" encoding="UTF-8"?> 
    <beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/batch"
    	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 
    	xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
           	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
          	http://www.springframework.org/schema/batch
          	http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
           	http://www.springframework.org/schema/aop
     		http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
    
    	
    	<job id="multiResourceJob" restartable="false">
    	  
    		<step id="fileStep1">
    		<tasklet ref="multiResourceReader" transaction-manager="transactionManager" />
    		</step> 
    	
    	</job>
    	
    	
    	
    	<beans:bean id="multiResourceReader" class="org.springframework.batch.item.file.MultiResourceItemReader">
    	   <beans:property name="resources" value="classpath:delimited*.csv" />
    	   <beans:property name="delegate" ref="flatFileItemReader" />
    	   
       </beans:bean>
    	
    	<beans:bean id ="flatFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
    				<beans:property name="lineMapper">
    					<beans:bean
    						class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
    						<beans:property name="lineTokenizer">
    							<beans:bean
    								class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
    								<beans:property name="delimiter" value="," />
    								<beans:property name="names" value="name,credit" />
    							</beans:bean>
    						</beans:property>
    						<beans:property name="fieldSetMapper">
    							<beans:bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
    								<beans:property name="targetType" value="abc.patni.com.CustomerCredit" />
    							</beans:bean>
    						</beans:property>
    					</beans:bean>
    				</beans:property>
    	</beans:bean>

  4. #4
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    the ref attribute of the tasklet element must refer to an implementation of Tasklet, not to an implementation of ItemReader (which MultiResourceItemReader is.)

    a Tasklet is transactional, potentially repeatable operation. You implement your own Tasklet when you need specific processing like uncompressing a ZIP archive or executing a system command.

    Spring Batch provides a ChunkOrientedTasklet for the common read-process-write batch pattern.

    I don't know what you want to do, but if you want to write somewhere what you read from the CSV files with the MultiResourceItemReader, use the nested chunk element in tasklet and refer to your reader and writer:

    Code:
    <step id="someStep">
      <tasklet>
        <chunk reader="reader" writer="writer" commit-interval="100" />
      </tasklet>			
    </step>
    And BTW, try to use the latest version of Spring Batch (2.1.5).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •