1 2 Previous Next 24 Replies Latest reply on Apr 13, 2012 9:57 AM by ziobleed Go to original post
      • 15. Re: Seam Transaction is not active: tx=TransactionImple
        swd847

        oops, stuffed the formatting:






        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.
        • 16. Re: Seam Transaction is not active: tx=TransactionImple
          asookazian

          Ok, thx for clarifying, I didn't know that.  Every time you turn around there's just one more rule to remember in Seam!


          So that explains why GKing used @PersistenceContext instead of @In here:


          @Stateful
          @Scope(SESSION)
          @Name("bookingList")
          @Restrict("#{identity.loggedIn}")
          @TransactionAttribute(REQUIRES_NEW)
          public class BookingListAction implements BookingList, Serializable
          {
             private static final long serialVersionUID = 1L;
             
             @PersistenceContext
             private EntityManager em;
             
             @In
             private User user;
             
             @DataModel
             private List<Booking> bookings;
             @DataModelSelection 
             private Booking booking;
             
             @Logger 
             private Log log;
             
             @Factory
             @Observer("bookingConfirmed")
             public void getBookings()
             {
                bookings = em.createQuery("select b from Booking b where b.user.username = :username order by b.checkinDate")
                      .setParameter("username", user.getUsername())
                      .getResultList();
             }
             
             public void cancel()
             {
                log.info("Cancel booking: #{bookingList.booking.id} for #{user.username}");
                Booking cancelled = em.find(Booking.class, booking.getId());
                if (cancelled!=null) em.remove( cancelled );
                getBookings();
                FacesMessages.instance().add("Booking cancelled for confirmation number #0", booking.getId());
             }
             
             public Booking getBooking()
             {
                return booking;
             }
             
             @Remove
             public void destroy() {}
          }



          And so is that why he used @PersistenceContext exclusively for all SFSBs in that app?


          And that would be probably the only scenario where you would not use @In to inject EntityManager in a Seam app?

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

            Now that I thought about it, this part is worrysome:



            However as the Seam-managed persistence context is propagated to any component
            within the conversation, it will be propagated to methods marked REQUIRES_NEW.

            Wouldn't it be better if there was a deployment exception or runtime warning or error in this case?  Or does Seam just ignore the TransactionAttributeType completely and treat it as REQUIRED?

            • 18. Re: Seam Transaction is not active: tx=TransactionImple
              fkj
              <blockquote>
              _Jubril Oyesiji wrote on May 01, 2009 21:24:_<br/>

              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 >)`

              </blockquote>

              I'm using Seam 2.2 with MySQL + JTA, but no EJB, and getting this exception too.

              I've even tried to add @TransactionAttribute(REQUIRES_NEW).

              Any ideas?

              Thanks for any help,
              Felipe
              • 19. Re: Seam Transaction is not active: tx=TransactionImple
                yanmania

                Hi,


                The answer is in the first reply. You are using a transaction for too long. How long is your treatment ?
                If you read JSR 220 (http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html) you can see that a transaction will never live forever :




                Chapter Timer Service : Transaction
                An enterprise bean typically creates a timer within the scope of a transaction. If the transaction is then
                rolled back, the timer creation is rolled back.

                An enterprise bean typically cancels a timer within a transaction. If the transaction is rolled back, the
                container rescinds the timer cancellation.

                The timeout callback method is typically has transaction attribute REQUIRED or REQUIRES NEW
                (Required or RequiresNew if the deployment descriptor is used to specify the transaction
                attribute). If the transaction is rolled back, the container retries the timeout.


                When you use @TransactionAttribute(REQUIRES NEW) wihtin another transaction the original transaction waits untill the new transaction ends. So if your new transaction lives more than 5 minutes (the default timeout of JBoss) you will have a transaction timeout. If you were using EJB you could managed transaction demarcation with the TransactionAttribute so that your transaction would never live more than 5 minutes.


                The other choice is to extend timeout...

                • 20. Re: Seam Transaction is not active: tx=TransactionImple
                  forge.forgejava.gmail.com

                  Today ,I have this problem too.I do this to fix the problem.
                  Drop the table ,and Create the table again
                  !

                  • 21. Re: Seam Transaction is not active: tx=TransactionImple
                    billevans
                    Interesting, though not very enlightening thread.  In our system, needless to say, we have the same problem.  However, in my case I have some idea how to recreate:


                    1) Issue a set of queries that I know are going to take more than 5 minutes, all within one transaction.  The point at which the query set hangs will be copying to a MySQL TMP data set.

                    2) Try to cancel the set of queries:  This is effectively initiated via org.hibernate.Session.cancelQuery method call.

                    3) Transaction finally aborts and when it does throws the JDBCExceptionReporter Transaction is not active.

                    4) Thereafter, later queries sometimes fail with same error but mostly they work.  Interestingly, the value of BasicAction in the exception is always the same.



                    So, my theory is that step 3 somehow renders some re-usable transaction object damaged in some way. Some flag that leaves it in ActionStatus.ABORT_ONLY maybe?  Then it when it gets re-used again it causes the same exception.

                    Any comments?


                    • 22. Re: Seam Transaction is not active: tx=TransactionImple
                      murali.chvmk

                      Anybody solveed this error. Please folks help me to resolve this.

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

                        In my experience this is not a hibernate, jboss or MySQL exception (although in some cases it might be, I don't know). This happens to me whenever I have a NullPointerException somewhere in a transaction. My guess would be that the NullPointerException throws the transaction into a not active state.


                        I usually print out a couple of method calls and find my NullPointerException.


                        Hope this helps someone


                        BTW this works for me in SEAM 2.2.0.GA, JBOSS 5.1 and MySQL 5.5.8

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

                          I solved by replacing the tag <h: commandLink> with <s: link > in xhtml page

                          Don't know why, maybe a phase problem...

                           


                          1 2 Previous Next