Hello,
I am trying to use Spring Batch with an HSQLDB repository. I am getting the following error when starting up my job:
org.springframework.transaction.CannotCreateTransa ctionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: invalid transaction state: active SQL-transaction
The context configuration is as follows:
The job context:Code:<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" lazy-init="true"> <property name="dataSource" ref="dataSource"/> <property name="nestedTransactionAllowed" value="true" /> <property name="defaultTimeout" value="30" /> </bean> <bean id="jobExplorer" class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="tablePrefix" value="batch_"/> </bean> <bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher" autowire-candidate="true"> <property name="jobRepository" ref="ajobRepository"/> <property name="taskExecutor"> <bean class="org.springframework.core.task.SyncTaskExecutor" /> </property> </bean> <bean id ="dq-etl-jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="transactionManager" ref="transactionManager"/> <property name="databaseType" value="hsql" /> <property name="tablePrefix" value="batch_"/> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> <property name="url" value="jdbc:hsqldb:hsql://localhost:9000/jobsdb" /> <property name="maxIdle" value="10"/> <property name="maxActive" value="100"/> <property name="maxWait" value="10000"/> <property name="testOnBorrow" value="false"/> <property name="testWhileIdle" value="true"/> <property name="defaultAutoCommit" value="false"/> </bean>
The error trace is:Code:<batch:step id="loadjob"> <batch:tasklet transaction-manager="transactionManager" > <batch:chunk reader="importReader" processor="importProcessor" writer="compositeWriter" commit-interval="200"/> <batch:transaction-attributes isolation="READ_COMMITTED" propagation="REQUIRES_NEW" /> <batch:listeners> <batch:listener ref="aCacheJdbcWriter"/> <batch:listener ref="aDwJdbcWriter"/> </batch:listeners> </batch:tasklet> </batch:step>
When looking at this listing the "returning Datasource" .I do not see where it actually obtained the DataSource in the debug output. I have created a new repository just for testing and the error continues. I have removed all attribute specifications and relied on defaults, and the error continues.Code:1109 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [org.springframework.batch.core.repository.JobRepository.getLastJobExecution]: PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE 1437 [main] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [jdbc:hsqldb:hsql://localhost:9000/jobsdb, UserName=job_user HSQL Database Engine Driver] for JDBC transaction 1437 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Changing isolation level of JDBC Connection [jdbc:hsqldb:hsql://localhost:9000/jobsdb, UserName=job_user, HSQL Database Engine Driver] to 8 1453 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
Using the in-memory repository results in everything working normal.
I assume something minor/silly, but its identification escapes me.
Thanks for you help


Reply With Quote