[jboss-cvs] JBossAS SVN: r63547 - in trunk: testsuite and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 18 08:49:03 EDT 2007
Author: adrian at jboss.org
Date: 2007-06-18 08:49:02 -0400 (Mon, 18 Jun 2007)
New Revision: 63547
Added:
trunk/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java
trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java
trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java
trunk/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java
trunk/testsuite/src/resources/tm/bmtcleanup/
trunk/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml
Modified:
trunk/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
trunk/testsuite/.classpath
trunk/testsuite/imports/sections/tm.xml
trunk/tomcat/.classpath
trunk/tomcat/src/main/org/jboss/web/tomcat/service/jca/CachedConnectionValve.java
Log:
Port JBAS-4487 from jboss-4.2
Modified: trunk/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java 2007-06-18 12:48:47 UTC (rev 63546)
+++ trunk/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java 2007-06-18 12:49:02 UTC (rev 63547)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.ejb.plugins;
import java.util.Hashtable;
@@ -84,7 +84,7 @@
RefAddr refAddr = new RefAddr("userTransaction")
{
/** This is never really serialized */
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = -8228448967597474960L;
public Object getContent()
{
@@ -215,29 +215,51 @@
log.error("Failed to get status", ex);
}
- switch (status)
+ try
{
- case Status.STATUS_ACTIVE :
- case Status.STATUS_COMMITTING :
- case Status.STATUS_MARKED_ROLLBACK :
- case Status.STATUS_PREPARING :
- case Status.STATUS_ROLLING_BACK :
- try
- {
- tm.rollback();
- }
- catch (Exception ex)
- {
- log.error("Failed to rollback", ex);
- }
- // fall through...
- case Status.STATUS_PREPARED :
+ switch (status)
+ {
+ case Status.STATUS_ACTIVE :
+ case Status.STATUS_COMMITTING :
+ case Status.STATUS_MARKED_ROLLBACK :
+ case Status.STATUS_PREPARING :
+ case Status.STATUS_ROLLING_BACK :
+ try
+ {
+ tm.rollback();
+ }
+ catch (Exception ex)
+ {
+ log.error("Failed to rollback", ex);
+ }
+ // fall through...
+ case Status.STATUS_PREPARED :
+ String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName()
+ + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)";
+ log.error(msg);
+
+ // the instance interceptor will discard the instance
+ throw new RemoteException(msg);
+ }
+ }
+ finally
+ {
+ Transaction tx = null;
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (SystemException ex)
+ {
+ log.error("Failed to suspend transaction", ex);
+ }
+ if (tx != null)
+ {
String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName()
- + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)";
+ + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ;
log.error(msg);
-
- // the instance interceptor will discard the instance
throw new RemoteException(msg);
+ }
}
}
@@ -254,23 +276,45 @@
log.error("Failed to get status", ex);
}
- switch (status)
+ try
{
- case Status.STATUS_COMMITTING :
- case Status.STATUS_MARKED_ROLLBACK :
- case Status.STATUS_PREPARING :
- case Status.STATUS_ROLLING_BACK :
- try
- {
- tm.rollback();
- }
- catch (Exception ex)
- {
- log.error("Failed to rollback", ex);
- }
- String msg = "BMT stateful bean '" + container.getBeanMetaData().getEjbName()
- + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status);
+
+ switch (status)
+ {
+ case Status.STATUS_COMMITTING :
+ case Status.STATUS_MARKED_ROLLBACK :
+ case Status.STATUS_PREPARING :
+ case Status.STATUS_ROLLING_BACK :
+ try
+ {
+ tm.rollback();
+ }
+ catch (Exception ex)
+ {
+ log.error("Failed to rollback", ex);
+ }
+ String msg = "BMT stateful bean '" + container.getBeanMetaData().getEjbName()
+ + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status);
+ log.error(msg);
+ }
+ }
+ finally
+ {
+ Transaction tx = null;
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (SystemException ex)
+ {
+ log.error("Failed to suspend transaction", ex);
+ }
+ if (tx != null)
+ {
+ String msg = "BMT stateful bean " + container.getBeanMetaData().getEjbName()
+ + " did not complete user transaction properly tx=" + tx;
log.error(msg);
+ }
}
}
Modified: trunk/testsuite/.classpath
===================================================================
--- trunk/testsuite/.classpath 2007-06-18 12:48:47 UTC (rev 63546)
+++ trunk/testsuite/.classpath 2007-06-18 12:49:02 UTC (rev 63547)
@@ -70,6 +70,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/system-jmx"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-deployers.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/jboss-aop-jdk50.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/jboss-standalone-aspect-library-jdk50.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/pluggable-instrumentor.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/jbossmq"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-aop-mc-int.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-aop-mc-int-src.zip"/>
Modified: trunk/testsuite/imports/sections/tm.xml
===================================================================
--- trunk/testsuite/imports/sections/tm.xml 2007-06-18 12:48:47 UTC (rev 63546)
+++ trunk/testsuite/imports/sections/tm.xml 2007-06-18 12:49:02 UTC (rev 63547)
@@ -35,5 +35,17 @@
<include name="org/jboss/test/tm/interfaces/**"/>
</fileset>
</jar>
+
+ <!-- build bmtcleanuptest.jar -->
+ <jar destfile="${build.lib}/bmtcleanuptest.jar">
+ <metainf dir="${build.resources}/tm/bmtcleanup">
+ <include name="*.xml"/>
+ </metainf>
+ <fileset dir="${build.classes}">
+ <patternset refid="common.test.client.classes"/>
+ <include name="org/jboss/test/tm/ejb/**"/>
+ <include name="org/jboss/test/tm/interfaces/**"/>
+ </fileset>
+ </jar>
</target>
</project>
Added: trunk/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java 2007-06-18 12:49:02 UTC (rev 63547)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.tm.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.jboss.test.tm.interfaces.BMTCleanUp;
+import org.jboss.test.util.ejb.SessionSupport;
+import org.jboss.tm.TransactionManagerLocator;
+
+/**
+ * BMTCleanUpBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BMTCleanUpBean extends SessionSupport
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6750278789142406435L;
+
+ public void ejbCreate()
+ {
+ }
+
+ public void doNormal() throws RemoteException
+ {
+ UserTransaction ut = sessionCtx.getUserTransaction();
+ try
+ {
+ ut.begin();
+ ut.commit();
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+
+ public void testIncomplete() throws RemoteException
+ {
+ BMTCleanUp remote = (BMTCleanUp) sessionCtx.getEJBObject();
+ try
+ {
+ remote.doIncomplete();
+ }
+ catch (RemoteException expected)
+ {
+ // expected
+ }
+ checkTransaction();
+ remote.doNormal();
+ }
+
+ public void doIncomplete() throws RemoteException
+ {
+ UserTransaction ut = sessionCtx.getUserTransaction();
+ try
+ {
+ ut.begin();
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+
+ public void testTxTimeout() throws RemoteException
+ {
+ BMTCleanUp remote = (BMTCleanUp) sessionCtx.getEJBObject();
+ try
+ {
+ remote.doTimeout();
+ }
+ catch (RemoteException expected)
+ {
+ // expected
+ }
+ checkTransaction();
+ remote.doNormal();
+ }
+
+ public void doTimeout() throws RemoteException
+ {
+ UserTransaction ut = sessionCtx.getUserTransaction();
+ try
+ {
+ ut.setTransactionTimeout(5);
+ ut.begin();
+ Thread.sleep(10000);
+ }
+ catch (InterruptedException ignored)
+ {
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+
+ private void checkTransaction() throws RemoteException
+ {
+ TransactionManager tm = TransactionManagerLocator.getInstance().locate();
+ try
+ {
+ Transaction tx = tm.getTransaction();
+ if (tx != null)
+ throw new RemoteException("There should be no transaction context: " + tx);
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java 2007-06-18 12:49:02 UTC (rev 63547)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.tm.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * BMTCleanUp.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BMTCleanUp extends EJBObject
+{
+ void doNormal() throws RemoteException;
+
+ void testIncomplete() throws RemoteException;
+
+ void doIncomplete() throws RemoteException;
+
+ void testTxTimeout() throws RemoteException;
+
+ void doTimeout() throws RemoteException;
+}
Added: trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java 2007-06-18 12:49:02 UTC (rev 63547)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.tm.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * BMTCleanUpHome.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BMTCleanUpHome extends EJBHome
+{
+ BMTCleanUp create() throws CreateException, RemoteException;
+}
Added: trunk/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java 2007-06-18 12:49:02 UTC (rev 63547)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.tm.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestSetup;
+import org.jboss.test.tm.interfaces.BMTCleanUp;
+import org.jboss.test.tm.interfaces.BMTCleanUpHome;
+
+/**
+ * Tests for BMT CleanUp
+ *
+ * @author adrian at jboss.com
+ * @version $Revision: 60501 $
+ */
+public class BMTCleanUpUnitTestCase extends JBossTestCase
+{
+ public BMTCleanUpUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return new JBossTestSetup(getDeploySetup(BMTCleanUpUnitTestCase.class, "bmtcleanuptest.jar"));
+ }
+
+ public void testIncomplete() throws Exception
+ {
+ BMTCleanUp bean = getBean();
+ bean.testIncomplete();
+ }
+
+ public void testTxTimeout() throws Exception
+ {
+ BMTCleanUp bean = getBean();
+ bean.testTxTimeout();
+ }
+
+ private BMTCleanUp getBean() throws Exception
+ {
+ BMTCleanUpHome home = (BMTCleanUpHome) getInitialContext().lookup("BMTCleanUp");
+ return home.create();
+ }
+}
Added: trunk/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml
===================================================================
--- trunk/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml (rev 0)
+++ trunk/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml 2007-06-18 12:49:02 UTC (rev 63547)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <display-name>TimeoutTests</display-name>
+
+ <enterprise-beans>
+ <session>
+ <description>A stateless bean used for bmt cleanup tests</description>
+ <ejb-name>BMTCleanUp</ejb-name>
+ <home>org.jboss.test.tm.interfaces.BMTCleanUpHome</home>
+ <remote>org.jboss.test.tm.interfaces.BMTCleanUp</remote>
+ <ejb-class>org.jboss.test.tm.ejb.BMTCleanUpBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Bean</transaction-type>
+ </session>
+ </enterprise-beans>
+
+</ejb-jar>
Modified: trunk/tomcat/.classpath
===================================================================
--- trunk/tomcat/.classpath 2007-06-18 12:48:47 UTC (rev 63546)
+++ trunk/tomcat/.classpath 2007-06-18 12:49:02 UTC (rev 63547)
@@ -42,6 +42,7 @@
<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/jboss-aop-jdk50.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/jboss-standalone-aspect-library-jdk50.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-dependency.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/security"/>
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/jca/CachedConnectionValve.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/jca/CachedConnectionValve.java 2007-06-18 12:48:47 UTC (rev 63546)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/jca/CachedConnectionValve.java 2007-06-18 12:49:02 UTC (rev 63547)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.web.tomcat.service.jca;
import java.io.IOException;
@@ -31,6 +31,7 @@
import javax.servlet.ServletException;
import javax.transaction.Status;
import javax.transaction.SystemException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.apache.catalina.Lifecycle;
@@ -49,7 +50,7 @@
* This valve checks for unclosed connections on a servlet request
*
* @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 56732 $
+ * @version $Revision: 57206 $
*/
public class CachedConnectionValve extends ValveBase implements Lifecycle
{
@@ -146,7 +147,7 @@
public void invoke(Request request, Response response) throws IOException, ServletException
{
if(ccm == null)
- throw new IllegalStateException("Please uncomment the dependency on CachedConnectionManager"
+ throw new IllegalStateException("Uncomment the dependency on CachedConnectionManager"
+ " in META-INF/jboss-service.xml of jbossweb-tomcatxxx.sar");
try
{
@@ -225,40 +226,74 @@
log.error("Failed to get status", ex);
}
- switch (status)
+ try
{
- case Status.STATUS_ACTIVE:
- case Status.STATUS_COMMITTING:
- case Status.STATUS_MARKED_ROLLBACK:
- case Status.STATUS_PREPARING:
- case Status.STATUS_ROLLING_BACK:
- try
+ switch (status)
+ {
+ case Status.STATUS_ACTIVE:
+ case Status.STATUS_COMMITTING:
+ case Status.STATUS_MARKED_ROLLBACK:
+ case Status.STATUS_PREPARING:
+ case Status.STATUS_ROLLING_BACK:
+ try
+ {
+ tm.rollback();
+ }
+ catch (Exception ex)
+ {
+ log.error("Failed to rollback", ex);
+ }
+ // fall through...
+ case Status.STATUS_PREPARED:
+ String servletName = "<Unknown>";
+ try
+ {
+ Wrapper servlet = request.getWrapper();
+ if (servlet != null)
+ {
+ servletName = servlet.getName();
+ if (servlet.getJspFile() != null)
+ servletName = servlet.getJspFile();
+ }
+ }
+ catch (Throwable ignored)
+ {
+ }
+
+ String msg = "Application error: " + servletName + " did not complete its transaction";
+ log.error(msg);
+ }
+ }
+ finally
+ {
+ try
+ {
+ Transaction tx = tm.suspend();
+ if (tx != null)
{
- tm.rollback();
- }
- catch (Exception ex)
- {
- log.error("Failed to rollback", ex);
- }
- // fall through...
- case Status.STATUS_PREPARED:
- String servletName = "<Unknown>";
- try
- {
- Wrapper servlet = request.getWrapper();
- if (servlet != null)
+ String servletName = "<Unknown>";
+ try
{
- servletName = servlet.getName();
- if (servlet.getJspFile() != null)
- servletName = servlet.getJspFile();
+ Wrapper servlet = request.getWrapper();
+ if (servlet != null)
+ {
+ servletName = servlet.getName();
+ if (servlet.getJspFile() != null)
+ servletName = servlet.getJspFile();
+ }
}
+ catch (Throwable ignored)
+ {
+ }
+ String msg = "Application error: " + servletName +
+ " did not complete its transaction suspended tx=" + tx ;
+ log.error(msg);
}
- catch (Throwable ignored)
- {
- }
-
- String msg = "Application error: " + servletName + " did not complete its transaction";
- log.error(msg);
+ }
+ catch (SystemException ex)
+ {
+ log.error("Failed to suspend transaction", ex);
+ }
}
}
}
More information about the jboss-cvs-commits
mailing list