[seam-commits] Seam SVN: r12236 - branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/persistence.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Mar 22 07:24:58 EDT 2010
Author: manaRH
Date: 2010-03-22 07:24:57 -0400 (Mon, 22 Mar 2010)
New Revision: 12236
Modified:
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java
Log:
JBPAPP-3954 back port of MPC fix
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-03-19 22:50:30 UTC (rev 12235)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-03-22 11:24:57 UTC (rev 12236)
@@ -22,6 +22,7 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Unwrap;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
import org.jboss.seam.core.Mutable;
import org.jboss.seam.core.Expressions.ValueExpression;
@@ -199,21 +200,36 @@
private void close()
{
- boolean transactionActive = false;
- try
+ if (Contexts.isEventContextActive())
{
- transactionActive = Transaction.instance().isActive();
+
+ boolean transactionActive = false;
+
+ try
+ {
+ UserTransaction tx = Transaction.instance();
+ try
+ {
+ transactionActive = tx.isActive();
+ }
+ catch (SystemException se)
+ {
+ log.debug("could not get transaction status while destroying persistence context");
+ }
+ }
+ catch (Exception e)
+ {
+ // WebSphere throws a javax.naming.ConfigurationException when Transaction.instance() is called during HTTP Session expiration
+ // and there is no JNDI lookup possible. See details there: JBSEAM-4332
+ log.warn("could not get transaction while destroying persistence context. (called during session expiration ?)");
+ }
+
+ if ( transactionActive )
+ {
+ throw new IllegalStateException("attempting to destroy the persistence context while an active transaction exists (try installing <transaction:ejb-transaction/>)");
+ }
}
- catch (SystemException se)
- {
- log.debug("could not get transaction status while destroying persistence context");
- }
- if ( transactionActive )
- {
- throw new IllegalStateException("attempting to destroy the persistence context while an active transaction exists (try installing <transaction:ejb-transaction/>)");
- }
-
if ( log.isDebugEnabled() )
{
log.debug("destroying seam managed persistence context for persistence unit: " + persistenceUnitJndiName);
More information about the seam-commits
mailing list