Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-4122

Propagation REQUIRES_NEW fails on JBoss Application Server 4.2.1 when keeping a JDBC Connection handle

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.5.1
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      My issue is same as that of the issue SPR-4077. I tried upgrading to the latest Spring 2.5 jar final but still i am getting the same issue.

      I am obtaining the error message as

      In this scenario also we have the call from the REQUIRED to the REQUIRES_NEWWe obtained the following error.

      07:18:14 DEBUG [] [Admin] util.spring.TweJtaTransactionManager - Suspending current transaction, creating new transaction with name [com.taxware.priya.util.sequence.interfaces.ICustomDBSequenceOrganizer.getSequenceNextVal]
      07:18:14 ERROR [] [Admin] util.sequence.CustomDBSequenceGenerator - Exception in getSequenceNextVal(). keyName = TJ_ACCOUNTING_METHOD_SEQ, dataSourceName= TweDSRef Message: Trying to change transaction TransactionImple < ac, BasicAction: a0359a9:6ba:4740d127:27a status: ActionStatus.RUNNING > in enlist!
      java.lang.IllegalStateException: Trying to change transaction TransactionImple < ac, BasicAction: a0359a9:6ba:4740d127:27a status: ActionStatus.RUNNING > in enlist!
      at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:525)
      at org.jboss.resource.connectionmanager.TxConnectionManager.transactionStarted(TxConnectionManager.java:328)
      at org.jboss.resource.connectionmanager.CachedConnectionManager.userTransactionStarted(CachedConnectionManager.java:360)

      1. mssql-ds.xml
        3 kB
        Kavipriya Gnanasambandam
      2. SpringConfig.xml
        4 kB
        Kavipriya Gnanasambandam

        Issue Links

          Activity

          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          I suppose your JDBC-based DAOs receive a reference to the "dataSource" bean directly? You need to define a separate TransactionAwareDataSourceProxy like as follows:

          <bean id="myDataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
          <property name="targetDataSource" ref="dataSource"/>
          <property name="reobtainTransactionalConnections" value="true"/>
          </bean>

          Your JDBC-based DAOs should then receive a reference to this "myDataSource" bean (or whatever you prefer to call it).

          So this is only about the JDBC access side of your code. It won't affect Hibernate access at all.

          Juergen

          Show
          juergen.hoeller Juergen Hoeller added a comment - I suppose your JDBC-based DAOs receive a reference to the "dataSource" bean directly? You need to define a separate TransactionAwareDataSourceProxy like as follows: <bean id="myDataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> <property name="targetDataSource" ref="dataSource"/> <property name="reobtainTransactionalConnections" value="true"/> </bean> Your JDBC-based DAOs should then receive a reference to this "myDataSource" bean (or whatever you prefer to call it). So this is only about the JDBC access side of your code. It won't affect Hibernate access at all. Juergen
          Hide
          kavipriya Kavipriya Gnanasambandam added a comment -

          I took the Spring 2.5.1 jar from the Nightly Snap shot and I have added the property you have provided to the Spring config file. But still i am getting the same issue. I have attached my Spring Config file and the datasource file.

          Thanks

          Show
          kavipriya Kavipriya Gnanasambandam added a comment - I took the Spring 2.5.1 jar from the Nightly Snap shot and I have added the property you have provided to the Spring config file. But still i am getting the same issue. I have attached my Spring Config file and the datasource file. Thanks
          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          What does your JDBC access code look like? Does it talk to the "myDataSource" and "loadDataSource" beans (the proxies) accordingly? How exactly does it handle its open Connection?

          Juergen

          Show
          juergen.hoeller Juergen Hoeller added a comment - What does your JDBC access code look like? Does it talk to the "myDataSource" and "loadDataSource" beans (the proxies) accordingly? How exactly does it handle its open Connection? Juergen
          Hide
          kavipriya Kavipriya Gnanasambandam added a comment -

          The issue is Jboss doesnot allow to suspend a transaction when there are any open connections associated to it.
          The same issue that we faced in hibernate. But now this is the issue with the JDBC connection where we open a connection then we suspend the transaction and try to create a new transaction.

          As we are having a connection open we are not able to suspend the transaction.

          As this is JDBC connection handling we have modified the code such a way that the connections are not left open before suspending the transaction.

          But is there anything that spring can do it from their side for this issue?

          Thanks

          Show
          kavipriya Kavipriya Gnanasambandam added a comment - The issue is Jboss doesnot allow to suspend a transaction when there are any open connections associated to it. The same issue that we faced in hibernate. But now this is the issue with the JDBC connection where we open a connection then we suspend the transaction and try to create a new transaction. As we are having a connection open we are not able to suspend the transaction. As this is JDBC connection handling we have modified the code such a way that the connections are not left open before suspending the transaction. But is there anything that spring can do it from their side for this issue? Thanks
          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          I do understand the scenario. The recent change in TransactionAwareDataSourceProxy was designed exactly for that scenario. If you obtain your Connection from that special DataSource, you'll get a proxy back which will transparently return the Connection and reobtain it accordingly.

          My suspicion is that your code is still talking to the original DataSource, not to the TransactionAwareDataSourceProxy. Can you please double-check that your code is set up correctly there, so that your JDBC access code actually receives a Connection proxy from the TransactionAwareDataSourceProxy? Check the Connection handle that your code receives there: Is it a raw JBoss Connection or is it a Spring Connection proxy? The raw JBoss Connection will not work with suspension, but the Spring Connection proxy should be able to handle that.

          Juergen

          Show
          juergen.hoeller Juergen Hoeller added a comment - I do understand the scenario. The recent change in TransactionAwareDataSourceProxy was designed exactly for that scenario. If you obtain your Connection from that special DataSource, you'll get a proxy back which will transparently return the Connection and reobtain it accordingly. My suspicion is that your code is still talking to the original DataSource, not to the TransactionAwareDataSourceProxy. Can you please double-check that your code is set up correctly there, so that your JDBC access code actually receives a Connection proxy from the TransactionAwareDataSourceProxy? Check the Connection handle that your code receives there: Is it a raw JBoss Connection or is it a Spring Connection proxy? The raw JBoss Connection will not work with suspension, but the Spring Connection proxy should be able to handle that. Juergen

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              kavipriya Kavipriya Gnanasambandam
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                10 years, 9 weeks, 5 days ago