Hi,
I'm using spring-batch 2.1.3. RELEASE and wanted to use it with spring 3.0.5.RELEASE. However, I found that late binding is not working (at least for stepExecutionContext) with this configuration. If I change the project to use spring 2.5.6 then it's working perfectly.
I'm using stepExecutionContext late binding for the itemReader in partitioned configuration as below:
During execution of itemReader I'm getting the error:Code:<bean class="org.springframework.batch.core.scope.StepScope" /> <job id="partitionJdbcJob" xmlns="http://www.springframework.org/schema/batch"> <step id="step1"> <partition step="step" partitioner="partitioner"> <handler grid-size="2" task-executor="taskExecutor"/> </partition> </step> </job> <step id="step" xmlns="http://www.springframework.org/schema/batch"> <tasklet allow-start-if-complete="true"> <chunk writer="writer" reader="reader" commit-interval="5" /> <listeners> <listener ref="fileNameListener" /> </listeners> </tasklet> </step> <!-- ##### INFRASTRUCTURE ######## --> <bean id="partitioner" class="com.test.batch.example.DataPartitioner"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecutor" /> <bean id="fileNameListener" class="com.test.batch.example.OutputFileListener" scope="step"> <property name="path" value="file:./target/output/jdbc/" /> </bean> <bean id="reader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step"> <property name="dataSource" ref="dataSource" /> <property name="rowMapper"> <bean class="com.test.batch.example.IncomingDataRowMapper" /> </property> <property name="sql"> <value> <![CDATA[ select ID, STATUS from INCOMING_DATA where DATA_TYPE = ? ]]> </value> </property> <property name="preparedStatementSetter"> <bean class="org.springframework.batch.core.resource.ListPreparedStatementSetter" scope="step"> <property name="parameters"> <list> <value>#{stepExecutionContext[type]}</value> </list> </property> </bean> </property> </bean> <bean id="writer" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"> <property name="resource" value="#{stepExecutionContext[outputFile]}" /> <property name="lineAggregator"> <bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"> <property name="delimiter" value="," /> <property name="fieldExtractor"> <bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"> <property name="names" value="id,status" /> </bean> </property> </bean> </property> </bean>
Instead of the value determined by partitioner a null value is passed.Code:2010-10-26 12:54:10,244 ERROR [org.springframework.batch.core.step.AbstractStep] - <Encountered an error executing the step> org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [select data_type from incoming_data group by data_type]; SQL state [null]; error code [17004]; Niepoprawny typ kolumny; nested exception is java.sql.SQLException: Niepoprawny typ kolumny at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) ....
If I changed the project to use spring 2.5.6 then it's working without any problems. Is it a known issue, or new bug ? Or I'm missing something...
I'd appreciate for any help.
P.S. In attachement you can find zipped STS project with spring 3.0 configured.
Regards,
Marcin


Reply With Quote
