Announcement Announcement Module
No announcement yet.
getConnection in JTA Transaction Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • getConnection in JTA Transaction

    I have configured org.springframework.transaction.jta.JtaTransaction Manager in my applicationContext.xml.

    I want to run a sql query in the transaction. How do i get the connection. DataSourceUtils.getConnection() doesnt seems to work.

  • #2
    I get the following exception on transaction commit

    Caused by: org.springframework.transaction.UnexpectedRollback Exception: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: null
    at mit(
    at org.springframework.transaction.jta.JtaTransaction Manager.doCommit(
    at atformTransactionManager.commit(AbstractPlatformTr
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:67)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
    at $Proxy36.searchNode(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De Code))
    at java.lang.reflect.Method.invoke( ed Code))
    at npointUsingReflection(
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :122)
    at com.fmr.xtrac.advice.ServiceAroundAdvice.invoke(Se
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(


    • #3
      Now that's a quite odd exception. WebSphere's transaction coordinator seems to throw a JTA RollbackException with no message, from a standard JTA UserTransaction.commit() call that Spring's JtaTransactionManager performs.

      This looks like WebSphere misbehavior to me: We should really get a proper exception message there, hinting at what went wrong. It might be the consequence of something going wrong previously, with WebSphere swallowing the root cause.

      Do you get that behavior for every transaction you're trying, or only for specific ones? Which resources are you accessing within your transaction - are they all properly set up WebSphere JNDI resources? Any other exceptions to be found (for example, in the server log) before that commit failure?



      • #4
        I just observed a line printed on my server console -
        "TimeoutManage I WTRN0006W: Transaction 57415344:000000000000000200000023edde90dbe7a068ab2 78756d6211453003a34b1b473657276657231[] has timed out after 120 seconds."

        I tried increasing the timeout in applicationContext in the following way
        searchNode*=PROPAGATION_REQUIRED,readOnly,timeout_ 300

        But in vain, i am still getting the same exception. it means timeout has not been set. Do you know how to set it.


        • #5
          A timeout specified in the Spring transaction attribute will be passed on to the JTA UserTransaction. If that doesn't seem to work on WebSphere, try increasing the default transaction timeout in WebSphere configuration, which is certainly possible (check the WebSphere docs).

          At least Spring's guess in the exception message seems to be right: the transaction indeed timed out. So I assume you have a transaction that takes longer than 120 seconds? Quite a long operation :-)



          • #6
            I had earlier configured HibernateTransactionManager and my code used to work in the default time of transaction.

            Since i have plugged in JtaTransactionManager, i am getting these timeout exceptions. I had to increase the timeout to 500s to make my code work.

            These fact raise questions on performance of JtaTransactions itself.


            • #7
              I have resolved this issue now.

              My code was working with HibernateTransactionManager because it has a timeout > 400 seconds.

              JtaTransactionManager uses transactions from application server. WSAD has a transaction timeout of 120 seconds.

              I increased WSAD's transaction timeout and it worked.