[seam-commits] Seam SVN: r13650 - examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/bootstrap.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Aug 27 17:09:24 EDT 2010


Author: dan.j.allen
Date: 2010-08-27 17:09:22 -0400 (Fri, 27 Aug 2010)
New Revision: 13650

Modified:
   examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.java
Log:
put in hack to work around GlassFish not being able to find UserTransaction in singleton


Modified: examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.java
===================================================================
--- examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.java	2010-08-27 19:33:57 UTC (rev 13649)
+++ examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/bootstrap/ApplicationInitializer.java	2010-08-27 21:09:22 UTC (rev 13650)
@@ -31,6 +31,7 @@
 import javax.inject.Inject;
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
+import javax.persistence.TransactionRequiredException;
 import javax.transaction.UserTransaction;
 
 import org.jboss.seam.examples.booking.model.Hotel;
@@ -116,9 +117,17 @@
    {
       try
       {
-         utx.begin();
-         entityManager.persist(entity);
-         utx.commit();
+         // work around bug in GlassFish that it cannot locate a UserTransaction
+         try
+         {
+            entityManager.persist(entity);
+         }
+         catch (TransactionRequiredException e)
+         {
+            utx.begin();
+            entityManager.persist(entity);
+            utx.commit();
+         }
       }
       catch (Exception e) 
       {



More information about the seam-commits mailing list