0 Replies Latest reply on Jun 19, 2014 1:47 AM by Kanagaraj R

    ARJUNA016051: thread is already associated with a transaction!

    Kanagaraj R Newbie


      Hello,

       

      I am working on the Jboss migration and I am using three XA datasources in my application.

       

      I am getting the following error (ARJUNA016051: thread is already associated with a transaction!) while invoking the user transaction.

       

       

      static final void beginUserTxn() throws Exception{

      try{

      UserTransaction userTxn  = null;

      TransactionDelegator.logger.debug("Start beginUserTxn");

      userTxn = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");

      int status = userTxn.getStatus();

      if (status == Status.STATUS_MARKED_ROLLBACK || status == Status.STATUS_ROLLEDBACK) {

      logger.info("Transaction was already started before the listener and is marked for rollback or rolled back from other thread,"

      " so doing rollback to disassociate it with current thread");

      logger.debug("End beginUserTxn");

      }

      userTxn.begin();

      catch(Exception e)

      {

      logger.info(" User transaction  Error : " , e);

      }

      }

      Please find the below stacktrace that I am getting.

       

      javax.transaction.NotSupportedException: BaseTransaction.checkTransactionState - ARJUNA016051: thread is already associated with a transaction!

      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:72)

      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.begin(BaseTransactionManagerDelegate.java:65)

      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:142)

      at com.mmm.eatm.service.dao.TransactionDelegator.beginUserTxn(TransactionDelegator.java:116)

      at com.mmm.eatm.web.manageassets.loadICS.LoadICSProcessBean.beginTxn(LoadICSProcessBean.java:147)

      at com.mmm.eatm.web.manageassets.loadICS.LoadICSProcessBean.loadICSAssets(LoadICSProcessBean.java:98)

      at com.mmm.eatm.web.manageassets.loadICS.LoadICSProcessBean.doAction(LoadICSProcessBean.java:55)

      at com.mmm.eatm.web.manageassets.loadICS.LoadICSAction.load(LoadICSAction.java:96)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

      at java.lang.reflect.Method.invoke(Unknown Source)

      at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)

      at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)

      at com.mmm.eatm.web.core.WebDispatchAction.execute(WebDispatchAction.java:42)

      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)

      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)

      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

      at com.mmm.eatm.web.core.filters.AppTransactionFilter.doFilter(AppTransactionFilter.java:106)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

      at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

      at com.mmm.eatm.web.core.filters.SessionMonitor.doFilter(SessionMonitor.java:91)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

      at java.lang.Thread.run(Unknown Source)

      Caused by: java.lang.IllegalStateException: BaseTransaction.checkTransactionState - ARJUNA016051: thread is already associated with a transaction!

      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.checkTransactionState(BaseTransaction.java:266)

      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:68)

      ... 42 more

       

       

      It will be very helpful if i get any solution for this issue.

       

      Thanks in advance.