Probably this is not a non common exception on Spring Batch 2.1.7, if you are doing UnitTest this error will not appear, but if you are going to deploy your application on WebLogic 10g, spring batch breaks on ItemWriter, so the first thought is something like having break with a database transaction, well this is the answer:
If you have a configuration like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<bean id="chunkHandler" class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean"> | |
<property name="chunkWriter" ref="chunkWriter" /> | |
<property name="step" ref="step" /> | |
</bean> | |
<bean id="resourcelessTransactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /> | |
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"> | |
<property name="transactionManager" ref="resourcelessTransactionManager" /> | |
</bean> | |
<batch:job id="testjob" job-repository="jobRepository" restartable="false"> | |
<batch:step id="step"> | |
.... |
This will be break with the following exception on your Weblogic:
This is because some id and version are having a bad update in your spring batch table, to fix this problem you will have to create a Database with the full tables defined in your spring batch jar file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.batch</groupId> | |
<artifactId>spring-batch-core</artifactId> | |
<version>2.1.7.RELEASE</version | |
</dependency> |
If you unzip the jar file you will find a 'schema-drop-'%DATABASE%'.sql' in "org/springframework/batch/core", you have to execute that script and re-deploy your application context with the folling configuration:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<bean id="resourcelessTransactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /> | |
<batch:job-repository id="jobRepository" | |
data-source="batchDataSource" transaction-manager="resourcelessTransactionManager" | |
isolation-level-for-create="SERIALIZABLE" table-prefix="BATCH_" | |
max-varchar-length="6000" /> | |
... |
Finally, this error will be fixed.
Best Regards,