1 2 Previous Next 24 Replies Latest reply on Apr 13, 2012 9:57 AM by ziobleed

    Seam Transaction is not active: tx=TransactionImple

    oyesiji77

      I keep getting the following exception when attempting to retrieve data from my Database



      15:17:30,007 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: null
      15:17:30,007 ERROR [JDBCExceptionReporter] Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57f10b:911:49fb4a4b:3e status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -3f57f10b:911:49fb4a4b:3e status: ActionStatus.ABORT_ONLY >)





      I am using Seam 2.1 and all i am doing is injecting the entityManager and attempting to retrieve Data from the database



           
      @In EntityManager entityManager;
           
           
                  */
                 @SuppressWarnings("unchecked")
                 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
                 public List<Colleges> findAll() {
                      log.info("finding all Colleges instances", new Object[]{});
                      try {
                           final String queryString = "select model from Colleges model";
                           Query query = entityManager.createQuery(queryString);
                           return query.getResultList();
                      } catch (Exception re) {
                           re.printStackTrace();
                           log.fatal("finding all Colleges instances Failed", new Object[]{});
                           //throw re;
                      }
                      return null;
           }

        • 1. Re: Seam Transaction is not active: tx=TransactionImple
          gonorrhea

          I have seen this happen several times in multiple Seam 2.0.x apps.  I have never been able to identify the root cause.  There is a JBoss wiki related to this but not very helpful (at least not in a Seam/EJB3/JPA context):


          http://www.jboss.org/auth/wiki/TxNotActive?action=e&windowstate=normal&mode=view


          jboss-service.xml (default):


          <mbean code="org.jboss.tm.TransactionManagerService"
                name="jboss:service=TransactionManager"
                xmbean-dd="resource:xmdesc/TransactionManagerService-xmbean.xml">
                <attribute name="TransactionTimeout">300</attribute>
                <!- - set to false to disable transaction demarcation over IIOP - ->
                <attribute name="GlobalIdsEnabled">true</attribute>
                <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
          
                <!- - Transaction Integrity Checking - ->
                <!- - Force a rollback if another thread is associated with the transaction at commit - ->
                <!- - <depends optional-attribute-name="TransactionIntegrityFactory"
                         proxy-type="org.jboss.tm.integrity.TransactionIntegrityFactory">
                   <mbean code="org.jboss.tm.integrity.FailIncompleteTransaction"
                          name="jboss:service=TransactionManager,plugin=TransactionIntegrity"/>
                </depends> - ->
             </mbean>



          It's possible that this exception is tx timeout related.  However, 300 secs is 5 mins.  In my use cases, I have not experienced any hanging that long during testing.  Also, it seems after some searching on JBoss Transactions forum, that it occurs in multi-thread and single-user scenarios.


          @Seam devs: plz address this problem and help identify root cause and fix and post sticky, etc.  The exception verbage is extremely user unfriendly.  Yes, this exception is most likely not Seam-specific, but I'm sure a lot of Seam devs using the EAP (JBoss stack) are running into this mind-bender.  thx.

          • 2. Re: Seam Transaction is not active: tx=TransactionImple
            gonorrhea

            The following link in JBoss transactions forum is helpful:


            http://www.jboss.org/index.html?module=bb&op=viewtopic&t=124299


            Mark Little:



            So Hibernate is setting the transaction to rollback only. This could be a MySQL issue: we've seen issues in other projects with MySQL running on Linux producing failures that do not show up on Windows or other OS-es. Maybe you can shift to a different database?

            In my case, we're using Windows OS with MSSQL 2005 RDBMS.


            Here is a related referenced thread:


            https://forum.hibernate.org/viewtopic.php?p=2369722


            I'm wondering if it has to do with too many open connections.  And if so, whether or not enabling Hibernate live statistics (getSummary()) would help troubleshoot this.


            Has anybody successfully performed root cause analysis on this problem?  And what exactly does that arcane exception mean?


            Transaction is not active: tx=TransactionImple < ac

            ?


            this seems so cryptic, kinda like translating hieroglyphics.


            I'm dying to understand this problem as it comes and goes quite often.


            • 3. Re: Seam Transaction is not active: tx=TransactionImple
              gonorrhea

              have you tried marking your findAll() method with @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) to see how it behaves?  IIRC, the exception is not reproducible with NOT_SUPPORTED...

              • 4. Re: Seam Transaction is not active: tx=TransactionImple
                gonorrhea

                here is another relevant link I posted on hibernate.org forum last month (so we can view some code as well):


                https://forum.hibernate.org/viewtopic.php?f=1&t=995754&p=2409096

                • 5. Re: Seam Transaction is not active: tx=TransactionImple
                  oyesiji77

                  Can this be a MySQL problem, Because i am using Mysql. The strange thing is that this happens whenever i invoke the method the first time

                  • 6. Re: Seam Transaction is not active: tx=TransactionImple
                    oyesiji77

                    Tried using NOT_SUPPORTED, still does not work

                    • 7. Re: Seam Transaction is not active: tx=TransactionImple
                      gonorrhea

                      How bout marking all (public) business methods with NOT_SUPPORTED?  Ultimately, you don't want to keep your methods demarcated as such but it may help in terms of trouble-shooting.

                      • 8. Re: Seam Transaction is not active: tx=TransactionImple

                        Whatever happened with this?  We are having the same problem on a query that takes a little bit (10 seconds) to return.

                        • 9. Re: Seam Transaction is not active: tx=TransactionImple
                          oyesiji77

                          I don't know if this has to do with the type and version of JVM being used because i noticed that when i switched from windows to MAC , I have never experienced the problem again


                          NB:Not suggesting that MAC is better than windows

                          • 10. Re: Seam Transaction is not active: tx=TransactionImple
                            serginho

                            maybe its something about your datasource, ... are you working with multiple databases??

                            • 11. Re: Seam Transaction is not active: tx=TransactionImple
                              swd847
                              @In EntityManager entityManager; and @TransactionAttribute(REQUIRES_NEW) are not compatible. This MAY be the root cause, but I am not sure. Try using either @PersistenceContext or @TransactionAttribute(REQUIRED) and make sure you have <transaction:ejb-transaction/> installed in components.xml.
                              • 12. Re: Seam Transaction is not active: tx=TransactionImple
                                asookazian

                                Stuart Douglas wrote on Jun 26, 2009 01:10:


                                @In EntityManager entityManager; and @TransactionAttribute(REQUIRES_NEW) are not compatible.


                                where is this documented?  why?  Never heard that before...

                                • 13. Re: Seam Transaction is not active: tx=TransactionImple
                                  asookazian

                                  I just disproved your statement above regarding @In and REQUIRES_NEW are not compatible.  I am getting no exceptions with the code below and the data is being output to the server.log accordingly while iterating thru the Lists.  Can someone please verify my finding? REQUIRES_NEW is not available when using Seam's @Transactional.  Why?  This seems like a disadvantage to using Seam tx mgmgt vs. EJB CMT...


                                  @Name("testRequiresNew")
                                  @Startup
                                  @Scope(ScopeType.APPLICATION)
                                  @Stateful
                                  public class TestRequiresNewAction implements TestRequiresNew {
                                  
                                       @In 
                                       private EntityManager entityManager;
                                       
                                       @In
                                       private TestRequiresNewAction testRequiresNew;
                                       
                                       @Logger
                                       private Log log;
                                       
                                       @Remove
                                       public void destroy() {
                                            log.info("TestRequiresNewAction: in destroy()");
                                       }
                                  
                                       @Create
                                       @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
                                       //@TransactionAttribute(TransactionAttributeType.REQUIRED)
                                       public void test1() {
                                            log.info("TestRequiresNewAction: in test1()");     
                                            List<ApplicationSetting> list = entityManager.createQuery("from ApplicationSetting").getResultList();
                                            for (ApplicationSetting as : list) {
                                                 log.info("as.getAddedDate() = "+as.getAddedDate());
                                            }
                                            testRequiresNew.test2();
                                       }
                                       
                                       @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
                                       public void test2() {
                                            log.info("TestRequiresNewAction: in test2()");     
                                            List<ApplicationSite> list = entityManager.createQuery("from ApplicationSite").getResultList();
                                            for (ApplicationSite as : list) {
                                                 log.info("as.getAddedDate() = "+as.getAddedDate());
                                            }
                                       }
                                  
                                  }

                                  • 14. Re: Seam Transaction is not active: tx=TransactionImple
                                    swd847

                                    I did not say you would get an exception. When using REQUIRES_NEW the SMPC will not get enlisted into the new transaction. To quote from the seam docs:


                                     If you are using EJB3 and mark your class or method @TransactionAttribute(REQUIRES_NEW) then the transaction and persistence context shouldn't be propagated to method calls on this object. However as the Seam-managed persistence context is propagated to any component within the conversation, it will be propagated to methods marked REQUIRES_NEW. Therefore, if you mark a method REQUIRES_NEW then you should access the entity manager using @PersistenceContext.
                                    


                                    1 2 Previous Next