Spring Framework
  1. Spring Framework
  2. SPR-4077

PROPAGATION_REQUIRES_NEW fails on JBoss 4.2.1 when using Hibernate connection release mode "on_close"

    Details

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

      Description

      My Issue is same as of the BUG which was already disucssed and fixed in the following URL

      http://opensource.atlassian.com/projects/spring/browse/SPR-1384

        Issue Links

          Activity

          Hide
          Juergen Hoeller added a comment -

          Could please provide details on the failure in your scenario: stacktrace etc?

          That previous bug was fixed, so we're not aware of any remaining issues on JBoss...

          Juergen

          Show
          Juergen Hoeller added a comment - Could please provide details on the failure in your scenario: stacktrace etc? That previous bug was fixed, so we're not aware of any remaining issues on JBoss... Juergen
          Hide
          Muthukumaran Madialagan added a comment -

          In our scenario we are having

          1)Bean A and Bean B
          2)The transaction attribute of Bean A is requires and the Transaction Attribute of Bean B is Requires New.
          3) Bean A calls Bean B by passing the datasource as an input parameter.
          4)When Bean A calls Bean B the current transaction of Bean A is suspended and new transaction is created. Then TransactionSyncronizationManager clears the transaction synchronization. While trying to initialise a new transaction the below exception is thrown.

          [JtaTransactionManager] Suspending current transaction, creating new transaction with name [com.priya...sequence.interfaces.ICustomMySequenceOrganizer.getSequenceNextVal]

          [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@1d16efc] for key [org.hibernate.impl.SessionFactoryImpl@895684] from thread [http-localhost%2F10.3.89.177-8080-1]

          [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization

          [STDERR] java.lang.IllegalStateException: Trying to change transaction TransactionImple < ac, BasicAction: a0359b1:4e3:4734f5c7:fc status: ActionStatus.RUNNING > in enlist!

          [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:525)

          [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.transactionStarted(TxConnectionManager.java:328)

          [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionManager.userTransactionStarted(CachedConnectionManager.java:360)

          [STDERR] at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:127)

          [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:724)

          [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:681)

          [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:396)

          [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:329)

          [STDERR] at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262)

          [STDERR] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)

          [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)

          [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

          [STDERR] at $Proxy89.getSequenceNextVal(Unknown Source)

          Show
          Muthukumaran Madialagan added a comment - In our scenario we are having 1)Bean A and Bean B 2)The transaction attribute of Bean A is requires and the Transaction Attribute of Bean B is Requires New. 3) Bean A calls Bean B by passing the datasource as an input parameter. 4)When Bean A calls Bean B the current transaction of Bean A is suspended and new transaction is created. Then TransactionSyncronizationManager clears the transaction synchronization. While trying to initialise a new transaction the below exception is thrown. [JtaTransactionManager] Suspending current transaction, creating new transaction with name [com.priya...sequence.interfaces.ICustomMySequenceOrganizer.getSequenceNextVal] [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@1d16efc] for key [org.hibernate.impl.SessionFactoryImpl@895684] from thread [http-localhost%2F10.3.89.177-8080-1] [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization [STDERR] java.lang.IllegalStateException: Trying to change transaction TransactionImple < ac, BasicAction: a0359b1:4e3:4734f5c7:fc status: ActionStatus.RUNNING > in enlist! [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:525) [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.transactionStarted(TxConnectionManager.java:328) [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionManager.userTransactionStarted(CachedConnectionManager.java:360) [STDERR] at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:127) [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:724) [STDERR] at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:681) [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:396) [STDERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:329) [STDERR] at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262) [STDERR] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [STDERR] at $Proxy89.getSequenceNextVal(Unknown Source)
          Hide
          Muthukumaran Madialagan added a comment -

          We tried setting the following two properties in the Spring Config file

          <property name="useTransactionAwareDataSource" value="true"/>

          <prop key="hibernate.connection.release_mode">after_statement</prop>

          The issue is solved. But the performance is bit slow after setting these properties.

          Is this the only solution for this issue? Or do we have any fix versions that spring is going to release?.

          We are using Spring.jar 2.0.2

          Show
          Muthukumaran Madialagan added a comment - We tried setting the following two properties in the Spring Config file <property name="useTransactionAwareDataSource" value="true"/> <prop key="hibernate.connection.release_mode">after_statement</prop> The issue is solved. But the performance is bit slow after setting these properties. Is this the only solution for this issue? Or do we have any fix versions that spring is going to release?. We are using Spring.jar 2.0.2
          Hide
          Juergen Hoeller added a comment -

          This is unfortunately a known problem, as outlined in SPR-1384: Hibernate in connection release mode "on_close" keeps hold on to a JDBC Connection for its entire lifetime, which causes a problem with suspending that Connection on JBoss (only on JBoss, actually - works fine on WebLogic and WebSphere, for example). The usual solution is to switch the connection release mode to "after_statement", as you figured out.

          We could consider explicitly disconnecting the Session on suspend (and also after a transaction completed), similar to what HibernateTransactionManager does when used with Open Session n View. Up to now, this wasn't necessary - as long as connection release mode "after_statement" was used on JBoss. Explicitly calling "disconnect()" on the Session would essentially be an improvement that enables "on_close" to work even on JBoss.

          Juergen

          Show
          Juergen Hoeller added a comment - This is unfortunately a known problem, as outlined in SPR-1384 : Hibernate in connection release mode "on_close" keeps hold on to a JDBC Connection for its entire lifetime, which causes a problem with suspending that Connection on JBoss (only on JBoss, actually - works fine on WebLogic and WebSphere, for example). The usual solution is to switch the connection release mode to "after_statement", as you figured out. We could consider explicitly disconnecting the Session on suspend (and also after a transaction completed), similar to what HibernateTransactionManager does when used with Open Session n View. Up to now, this wasn't necessary - as long as connection release mode "after_statement" was used on JBoss. Explicitly calling "disconnect()" on the Session would essentially be an improvement that enables "on_close" to work even on JBoss. Juergen
          Hide
          Juergen Hoeller added a comment -

          I've addressed this for Spring 2.5 final: Hibernate SpringSessionSynchronization explicitly disconnects on suspend/completion now, in order to make "on_close" work on JBoss.

          This will be available in the upcoming Spring 2.5 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Please give it a try and let me know whether it works for you (with the default connection release mode "on_close"). Dropping Spring 2.5 final jars into a Spring 2.0.x based application should be straightforward. Just note that spring-webmvc.jar needs to be added explicitly now; it is not part of spring.jar anymore.

          Juergen

          Show
          Juergen Hoeller added a comment - I've addressed this for Spring 2.5 final: Hibernate SpringSessionSynchronization explicitly disconnects on suspend/completion now, in order to make "on_close" work on JBoss. This will be available in the upcoming Spring 2.5 snapshot ( http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR ). Please give it a try and let me know whether it works for you (with the default connection release mode "on_close"). Dropping Spring 2.5 final jars into a Spring 2.0.x based application should be straightforward. Just note that spring-webmvc.jar needs to be added explicitly now; it is not part of spring.jar anymore. Juergen
          Hide
          Muthukumaran Madialagan added a comment -

          Thanks a lot for your suggestion it was very helpful.

          We tried with Spring2.5.jar final the issue got solved.

          But we have few questions on the same.

          1) We are having release targeted this weekend. So we cant go ahead using Spring 2.5 jar because it is not officially released. Can you please let us know the targeted release for the Spring 2.5 jar.

          2)What will be performance impact if we use the property after_statement. Because in our application after we use the property after_statement we find the performance to be bit slow when we land in create calls.

          For Example:

          We have 10 connections we do a create call the performance was good before using the after_statement property. After we use the property after_statement with the same 10 connections the performance is slow for the same scenario. Do we need to compromise on the performance if we introduce this property?

          3) You have fixed this issue in the Spring 2.5 jar can you please let us know is there any way we can do the same fix in the Spring 2.0.2.jar so that the issue might get solved.

          Thanks.

          Show
          Muthukumaran Madialagan added a comment - Thanks a lot for your suggestion it was very helpful. We tried with Spring2.5.jar final the issue got solved. But we have few questions on the same. 1) We are having release targeted this weekend. So we cant go ahead using Spring 2.5 jar because it is not officially released. Can you please let us know the targeted release for the Spring 2.5 jar. 2)What will be performance impact if we use the property after_statement. Because in our application after we use the property after_statement we find the performance to be bit slow when we land in create calls. For Example: We have 10 connections we do a create call the performance was good before using the after_statement property. After we use the property after_statement with the same 10 connections the performance is slow for the same scenario. Do we need to compromise on the performance if we introduce this property? 3) You have fixed this issue in the Spring 2.5 jar can you please let us know is there any way we can do the same fix in the Spring 2.0.2.jar so that the issue might get solved. Thanks.
          Hide
          Juergen Hoeller added a comment -

          "after_statement" should actually work fine, provided that the underlying connection pool is efficient. This setting is what the Hibernate guys recommend, so I wonder about negative effects on JBoss (their 'own' application server) there? This is also why we consider the "on_close" support to be an improvement rather than a bug fix...

          Still, there may be a performance impact. So I would recommend to upgrade to Spring 2.5 as soon as you can. You may of course deploy with "after_statement" for the initial phase of your application, even if performance is suffering a little bit...

          Spring 2.5 final will be released on Nov 19th - in less than a week. You can make sure that the 2.5 upgrade will be smooth by testing your entire application against the latest 2.5 snapshot (as you already started); then you'll know that 2.5 final will be a drop-in upgrade.

          Juergen

          Show
          Juergen Hoeller added a comment - "after_statement" should actually work fine, provided that the underlying connection pool is efficient. This setting is what the Hibernate guys recommend, so I wonder about negative effects on JBoss (their 'own' application server) there? This is also why we consider the "on_close" support to be an improvement rather than a bug fix... Still, there may be a performance impact. So I would recommend to upgrade to Spring 2.5 as soon as you can. You may of course deploy with "after_statement" for the initial phase of your application, even if performance is suffering a little bit... Spring 2.5 final will be released on Nov 19th - in less than a week. You can make sure that the 2.5 upgrade will be smooth by testing your entire application against the latest 2.5 snapshot (as you already started); then you'll know that 2.5 final will be a drop-in upgrade. Juergen
          Hide
          Muthukumaran Madialagan added a comment -

          We have postponed our release to 21st of November hoping that the Spring 2.5 final will be released on 19th of November.

          Till 19th can we test our application with the upcoming Spring 2.5 snapshot provided by you in the link (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). ?

          Will there be any difference between the Spring 2.5 snap shot provided and the final release on November 19th?

          Thanks.

          Show
          Muthukumaran Madialagan added a comment - We have postponed our release to 21st of November hoping that the Spring 2.5 final will be released on 19th of November. Till 19th can we test our application with the upcoming Spring 2.5 snapshot provided by you in the link ( http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR ). ? Will there be any difference between the Spring 2.5 snap shot provided and the final release on November 19th? Thanks.
          Hide
          Juergen Hoeller added a comment -

          Yes, the nightly snapshots that we publish once a day reflect the most current 2.5 code. Until the 19th, we'll only be doing bug fixes and doc enhancements, so no major changes to be expected.

          Juergen

          Show
          Juergen Hoeller added a comment - Yes, the nightly snapshots that we publish once a day reflect the most current 2.5 code. Until the 19th, we'll only be doing bug fixes and doc enhancements, so no major changes to be expected. Juergen

            People

            • Assignee:
              Juergen Hoeller
              Reporter:
              Muthukumaran Madialagan
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 23 weeks, 6 days ago