Announcement Announcement Module
Collapse
No announcement yet.
getConnection in JTA Transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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
    javax.transaction.RollbackException
    at com.ibm.ws.Transaction.JTA.TransactionImpl.commit( TransactionImpl.java:1076)
    at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit( TranManagerImpl.java:150)
    at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(T ranManagerSet.java:182)
    at com.ibm.ws.Transaction.JTA.UserTransactionImpl.com mit(UserTransactionImpl.java:262)
    at org.springframework.transaction.jta.JtaTransaction Manager.doCommit(JtaTransactionManager.java:710)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:435)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:258)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:67)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy36.searchNode(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java(Compiled Code))
    at java.lang.reflect.Method.invoke(Method.java(Compil ed Code))
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:288)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:155)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :122)
    at com.fmr.xtrac.advice.ServiceAroundAdvice.invoke(Se rviceAroundAdvice.java:82)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)

    Comment


    • #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?

      Juergen

      Comment


      • #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.

        Comment


        • #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 :-)

          Juergen

          Comment


          • #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.

            Comment


            • #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.

              Comment

              Working...
              X