Announcement Announcement Module
Collapse
No announcement yet.
LazyConnectionDataSourceProxy in Spring batch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LazyConnectionDataSourceProxy in Spring batch

    When I am using LazyConnectionDataSourceProxy with Spring batch I am getting following exception.

    I have to remove LazyConnectionDataSourceProxy to use Spring batch. Any thoughts?

    Code:
    org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; SQL state [null]; error code [0]; Cannot set auto-commit mode when using distributed transactions; nested exception is java.sql.SQLException: Cannot set auto-commit mode when using distributed transactions
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:204) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:209) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.getJobInstance(JdbcJobInstanceDao.java:223) ~[spring-batch-core-2.1.8.RELEASE.jar:na]
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.getLastJobExecution(SimpleJobRepository.java:253) ~[spring-batch-core-2.1.8.RELEASE.jar:na]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_29]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_29]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_29]
    	at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_29]
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) ~[org.springframework.transaction-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at $Proxy109.getLastJobExecution(Unknown Source) ~[na:na]
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:94) ~[spring-batch-core-2.1.8.RELEASE.jar:na]
    Caused by: java.sql.SQLException: Cannot set auto-commit mode when using distributed transactions
    	at weblogic.jdbc.wrapper.JTAConnection.setAutoCommit(JTAConnection.java:318) ~[com.bea.core.datasource6_1.10.0.0.jar:1.10.0.0]
    	at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.getTargetConnection(LazyConnectionDataSourceProxy.java:417) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at $Proxy133.prepareStatement(Unknown Source) ~[na:na]
    	at org.springframework.jdbc.core.JdbcTemplate$SimplePreparedStatementCreator.createPreparedStatement(JdbcTemplate.java:1436) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:581) ~[org.springframework.jdbc-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	... 48 common frames omitted

  • #2
    Can you post the configuration of your datasource and transaction manager?

    Comment


    • #3
      When I set 'regularOrclDS' to jobRepository bean it works fine. I get above exception when I pass 'orclDS'.


      Code:
      	<bean id="transactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager">
      		<property name="transactionManagerName" value="javax.transaction.TransactionManager" />
      	</bean>
              
              <jee:jndi-lookup id="regularOrclDS" jndi-name="DS_ORCL" cache="true" resource-ref="true" lookup-on-startup="true"/>
      
              <bean id="orclDS" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
      		<constructor-arg ref="regularOrclDS" />
      	</bean>
      
      	<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
      		p:dataSource-ref="orclDS" p:transactionManager-ref="transactionManager" p:table-prefix="BATCH_" 
      		p:databaseType="ORACLE" />

      Comment


      • #4
        Why are you wrapping a datasource provided by JNDI in the LazyConnectionDataSourceProxy? Your container is already creating the connections irrespective of if they have been requested by your application or not, so what benefit does the LazyConnectionDataSourceProxy provide in this case?

        Comment


        • #5
          My other part of the application uses EclipseLink JPA and Spring Data. Please refer following links:

          http://static.springsource.org/sprin...paDialect.html

          http://jolbox.com/blog/?p=22

          Comment

          Working...
          X