8 Replies Latest reply on Jul 22, 2011 2:58 AM by lowecg2004

    Non-EE Thread Access to UserTransaction (Seam Asynchronous Quartz Tx Problem)

    lowecg2004

      Hello,

       

      I've been having some trouble with a transactional asychronous Quartz based task in a Seam application since moving to AS7.

      The problem I'm having that every time an async process is fired, I see the error message could not discover transaction status in the logs.  The application is WAR based and uses Seam 2.2.2.Final.

       

      Looking at the Seam code,  the following method is responsible for accessing a UserTransaction from a Quartz thread and is the source (Transaction.java) of the error:

       

         protected javax.transaction.UserTransaction getUserTransaction() throws NamingException

         {

            InitialContext context = Naming.getInitialContext();

            try

            {

               return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");

            }

            catch (NameNotFoundException nnfe)

            {

               try

               {

                  //Embedded JBoss has no java:comp/UserTransaction

                  javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction) context.lookup("UserTransaction");

                  ut.getStatus(); //for glassfish, which can return an unusable UT

                  return ut;

               }

               catch (Exception e)

               {

                  throw nnfe;

               }

            }

         }

       

      Under AS6 the second lookup succeeds from a Quartz thread, however both lookups fail under AS7.

       

      While hunting around for a possible solution, I came across the following discussion on the AS7 dev list which states that global UserTransaction from non-EE threads used to be handled specifically under AS6 but that is no longer the case in AS7:

       

      http://lists.jboss.org/pipermail/jboss-as7-dev/2011-June/002290.html

       

      I'm assuming that the Quartz worker threads are counted as "non-EE threads".  I was wondering if there is any way at all to access UserTransaction from a Quartz thread in AS7?  I don't mind doing some leg work on this but I really could use some pointers to get started.

       

      Best regards,

       

      Chris.