3 Replies Latest reply on May 4, 2009 2:46 PM by dragos cernahoschi

    BaseTransaction.checkTransactionState - thread is already associated with a transaction

    Monkey Den Master

      I have a controller component (PayorAccountController) which is managing a Stack of EntityHome instances (PayorAccountHome).  I have some other stub methods (not included) which don't do anything at the moment.  I originally tried nested conversations to get a recursive EntityHome effect but that was an unpredictable nightmare.  In PayorAccountController, after the line with current.setPayerId(payerId) I get this exception:


      Caused by: java.lang.IllegalStateException: BaseTransaction.checkTransactionState - [com.arjuna.ats.internal.jta.transaction.arjunacore.alreadyassociated] [com.arjuna.ats.internal.jta.transaction.arjunacore.alreadyassociated] thread is already associated with a transaction!
           at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.checkTransactionState(BaseTransaction.java:308)
           at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple.resume(TransactionManagerImple.java:103)
           at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.resume(BaseTransactionManagerDelegate.java:117)
           at org.jboss.aspects.tx.TxInterceptor$NotSupported.invoke(TxInterceptor.java:106)
           at org.jboss.portal.core.aspects.portlet.TransactionInterceptor$invokeNotSupported_N6922078035659651697.invokeNext(TransactionInterceptor$invokeNotSupported_N6922078035659651697.java)
           at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.invokeNotSupported(TransactionInterceptor.java)
           at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.core.aspects.portlet.HeaderInterceptor.invoke(HeaderInterceptor.java:49)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.aspects.portlet.EventPayloadInterceptor.invoke(EventPayloadInterceptor.java:196)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.aspects.portlet.RequestAttributeConversationInterceptor.invoke(RequestAttributeConversationInterceptor.java:119)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.core.aspects.portlet.SignOutInterceptor.invoke(SignOutInterceptor.java:43)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.core.aspects.portlet.AjaxInterceptor.invoke(AjaxInterceptor.java:49)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.core.aspects.portlet.BackwardCompatibilityInterceptor.invoke(BackwardCompatibilityInterceptor.java:46)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.bridge.BridgeInterceptor.invoke(BridgeInterceptor.java:49)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.aspects.portlet.PortletSessionSynchronizationInterceptor.invoke(PortletSessionSynchronizationInterceptor.java:82)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.aspects.portlet.ContextTrackerInterceptor.invoke(ContextTrackerInterceptor.java:48)
           at org.jboss.portal.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:82)
           at org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor.access$001(ContextDispatcherInterceptor.java:49)
           at org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor$1.doCallback(ContextDispatcherInterceptor.java:123)
           at org.jboss.portal.web.command.CommandDispatcher$CallbackCommand.execute(CommandDispatcher.java:74)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.portal.web.command.CommandServlet.doGet(CommandServlet.java:130)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
           at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
           at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
           at org.jboss.portal.web.command.CommandServlet.include(CommandServlet.java:79)
           at org.jboss.portal.web.command.CommandDispatcher.include(CommandDispatcher.java:50)
           at org.jboss.portal.web.jboss.JBossWebContext.include(JBossWebContext.java:66)
           at org.jboss.portal.web.impl.DefaultServletContainer.include(DefaultServletContainer.java:190)
           at org.jboss.portal.portlet.impl.spi.AbstractServerContext.dispatch(AbstractServerContext.java:69)
           at org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor.invoke(ContextDispatcherInterceptor.java:77)
      



      Clearly it appears that Seam is attempting to create another transaction, when one is already available.  Is there anything else required of my bean to get this to work?


      The controller


      @Name("payorAcountController")
      @Scope(CONVERSATION)
      public class PayorAccountController {
          private Stack<PayorAccountHome> payers;
      
          public void setPayerId(Integer payerId) {
              log.debug("Loading payer #0", payerId);
      
              //create new PayorAccountHome with the id
              PayorAccountHome current = (PayorAccountHome)Component.getInstance(PayorAccountHome.class, true);
              current.setPayerId(payerId);//this just calls EntityHome.setId()
      
              //push it onto the list
              payers.push(current);
      
              //Set it as the current
              setCurrentPayer(current);
          }
      
          public String cancel(){
              String result = null;
              payers.pop();
      
              if(payers.empty()){
                  result = "search";
              }else{
                  currentPayer = payers.peek();
                  result = "edit";
              }
              return result;
          }
          ...
      
      }



      The HomeObject


      @Name("payorAccountHome")
      @Scope(ScopeType.CONVERSATION)
      public class PayorAccountHome extends StaticHomeController<Payer> {
      
          ....
          public Integer getPayerId() {
              return (Integer) getId();
          }
      
          public void setPayerId(Integer payerId) {
              setId(payerId);
          }
      
          @Override
          public Payer createInstance(){
              Payer payer = new Payer();
              Country country = countryMap.get(PayorAccountHome.DEFAULT_COUNTRY);
              payer.setCountry(country);
      
              return payer;
          }
      
      }
      



      Help is appreciated
      Thanks