cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject git commit: CXF-5543 Test for JTA
Date Tue, 15 Apr 2014 08:45:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/master b4c680ae6 -> 642cf8dd0


CXF-5543 Test for JTA


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/642cf8dd
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/642cf8dd
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/642cf8dd

Branch: refs/heads/master
Commit: 642cf8dd0ade538995be3d5cfd90bdd3c5df3f36
Parents: b4c680a
Author: Christian Schneider <chris@die-schneider.net>
Authored: Tue Apr 15 10:45:24 2014 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Apr 15 10:45:24 2014 +0200

----------------------------------------------------------------------
 rt/transports/jms/pom.xml                       | 321 +++++++++----------
 .../cxf/transport/jms/JMSConfigFactory.java     |  44 +++
 .../cxf/transport/jms/JMSConfiguration.java     |  12 +-
 .../cxf/transport/jms/JMSDestination.java       |  42 ++-
 .../cxf/transport/jms/uri/JMSEndpoint.java      |  10 +
 .../apache/cxf/transport/jms/util/JMSUtil.java  |  30 +-
 .../util/PollingMessageListenerContainer.java   |   1 +
 .../cxf/transport/jms/util/ResourceCloser.java  |   1 +
 .../cxf/transport/jms/JMSConfigFactoryTest.java |  52 ++-
 .../cxf/transport/jms/uri/JMSEndpointTest.java  |   5 +
 .../cxf/transport/jms/uri/MyBeanLocator.java    |   3 +-
 .../transport/jms/util/MessageListenerTest.java |  42 +--
 systests/transport-jms/pom.xml                  |   6 +
 .../cxf/systest/jms/AbstractVmJMSTest.java      |  52 ++-
 .../cxf/systest/jms/JMSClientServerTest.java    |   2 -
 .../continuations/HWSoapMessageDocProvider.java |   2 -
 .../systest/jms/shared/JMSSharedQueueTest.java  |   1 -
 .../jms/tx/GreeterImplWithTransaction.java      |  45 +--
 .../jms/tx/JMSTransactionClientServerTest.java  |  73 -----
 .../cxf/systest/jms/tx/JMSTransactionTest.java  | 165 ++++++++++
 .../cxf/systest/jms/tx/MyBeanLocator.java       |  80 +++++
 .../cxf/systest/jms/tx/jms_server_config.xml    |  33 --
 22 files changed, 658 insertions(+), 364 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/jms/pom.xml b/rt/transports/jms/pom.xml
index 48a0bd4..4f5530c 100644
--- a/rt/transports/jms/pom.xml
+++ b/rt/transports/jms/pom.xml
@@ -1,166 +1,159 @@
 <?xml version="1.0"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
- 
-  http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied. See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>cxf-rt-transports-jms</artifactId>
-    <packaging>bundle</packaging>
-    <name>Apache CXF Runtime JMS Transport</name>
-    <description>Apache CXF Runtime JMS Transport</description>
-    <url>http://cxf.apache.org</url>
-    <parent>
-        <groupId>org.apache.cxf</groupId>
-        <artifactId>cxf-parent</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
-        <relativePath>../../../parent/pom.xml</relativePath>
-    </parent>
-    <properties>
-        <cxf.spi-dir>spi-2.1</cxf.spi-dir>
-    </properties>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-wsdl</artifactId>
-            <version>${project.version}</version>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jms_1.1_spec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jta_1.1_spec</artifactId>
-            <version>1.1.1</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-lang</groupId>
-            <artifactId>commons-lang</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
-            <scope>provided</scope>
-            <optional>true</optional>
-        </dependency>
-        
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-management</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-bindings-soap</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-testutils</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.activemq</groupId>
-            <artifactId>activemq-broker</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.activemq</groupId>
-            <artifactId>activemq-pool</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.activemq</groupId>
-            <artifactId>activemq-kahadb-store</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.xbean</groupId>
-            <artifactId>xbean-spring</artifactId>
-            <version>3.5</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-jdk14</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-        	<groupId>org.apache.aries.transaction</groupId>
-        	<artifactId>org.apache.aries.transaction.manager</artifactId>
-        	<version>1.1.0</version>
-        	<scope>test</scope>
-        </dependency>
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.cxf</groupId>
-                <artifactId>cxf-xjc-plugin</artifactId>
-                <version>${cxf.xjc-utils.version}</version>
-                <executions>
-                    <execution>
-                        <id>generate-sources</id>
-                        <phase>generate-sources</phase>
-                        <configuration>
-                            <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
-                            <xsdOptions>
-                                <xsdOption>
-                                    <xsd>${basedir}/src/main/resources/schemas/wsdl/spec/jms-spec-wsdl.xsd</xsd>
-                                    <bindingFile>${basedir}/src/main/resources/schemas/wsdl/spec/jms-spec-wsdl.xjb</bindingFile>
-                                </xsdOption>
-                            </xsdOptions>
-                        </configuration>
-                        <goals>
-                            <goal>xsdtojava</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <extensions>
-                        <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:${cxf.xjc-utils.version}</extension>
-                    </extensions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+	license agreements. See the NOTICE file distributed with this work for additional 
+	information regarding copyright ownership. The ASF licenses this file to 
+	you under the Apache License, Version 2.0 (the "License"); you may not use 
+	this file except in compliance with the License. You may obtain a copy of 
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+	by applicable law or agreed to in writing, software distributed under the 
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+	OF ANY KIND, either express or implied. See the License for the specific 
+	language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>cxf-rt-transports-jms</artifactId>
+	<packaging>bundle</packaging>
+	<name>Apache CXF Runtime JMS Transport</name>
+	<description>Apache CXF Runtime JMS Transport</description>
+	<url>http://cxf.apache.org</url>
+	<parent>
+		<groupId>org.apache.cxf</groupId>
+		<artifactId>cxf-parent</artifactId>
+		<version>3.0.0-SNAPSHOT</version>
+		<relativePath>../../../parent/pom.xml</relativePath>
+	</parent>
+	<properties>
+		<cxf.spi-dir>spi-2.1</cxf.spi-dir>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-core</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-wsdl</artifactId>
+			<version>${project.version}</version>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jms_1.1_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jta_1.1_spec</artifactId>
+			<version>1.1.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+			<scope>provided</scope>
+			<optional>true</optional>
+		</dependency>
+
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.easymock</groupId>
+			<artifactId>easymock</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-management</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-bindings-soap</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-testutils</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-broker</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-pool</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-kahadb-store</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.xbean</groupId>
+			<artifactId>xbean-spring</artifactId>
+			<version>3.5</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-jdk14</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.components</groupId>
+			<artifactId>geronimo-transaction</artifactId>
+			<version>3.1.1</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.cxf</groupId>
+				<artifactId>cxf-xjc-plugin</artifactId>
+				<version>${cxf.xjc-utils.version}</version>
+				<executions>
+					<execution>
+						<id>generate-sources</id>
+						<phase>generate-sources</phase>
+						<configuration>
+							<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
+							<xsdOptions>
+								<xsdOption>
+									<xsd>${basedir}/src/main/resources/schemas/wsdl/spec/jms-spec-wsdl.xsd</xsd>
+									<bindingFile>${basedir}/src/main/resources/schemas/wsdl/spec/jms-spec-wsdl.xjb</bindingFile>
+								</xsdOption>
+							</xsdOptions>
+						</configuration>
+						<goals>
+							<goal>xsdtojava</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<extensions>
+						<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:${cxf.xjc-utils.version}</extension>
+					</extensions>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFactory.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFactory.java
index c549fa4..2f30507 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFactory.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfigFactory.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.transport.jms;
 
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.Map;
 import java.util.Properties;
@@ -27,6 +28,9 @@ import java.util.logging.Logger;
 import javax.jms.ConnectionFactory;
 import javax.jms.DeliveryMode;
 import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
@@ -84,6 +88,10 @@ public final class JMSConfigFactory {
         jmsConfig.setConduitSelectorPrefix(endpoint.getConduitIdSelectorPrefix());
         jmsConfig.setUserName(endpoint.getUsername());
         jmsConfig.setPassword(endpoint.getPassword());
+
+        TransactionManager tm = getTransactionManager(bus, endpoint);
+        jmsConfig.setTransactionManager(tm);
+        
         if (endpoint.getJndiURL() != null) {
             // Configure Connection Factory using jndi
             jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));
@@ -126,6 +134,28 @@ public final class JMSConfigFactory {
         return jmsConfig;
     }
 
+    private static TransactionManager getTransactionManager(Bus bus, JMSEndpoint endpoint) {
+        String tmName = endpoint.getJndiTransactionManagerName();
+        TransactionManager tm = null;
+        ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
+        if (tmName != null) {
+            if (locator != null) {
+                tm = locator.getBeanOfType(tmName, TransactionManager.class);
+            }
+            if (tm == null) {
+                tm = getTransactionManagerFromJndi(tmName);
+            }
+            
+        }
+        if (tm == null && locator != null) {
+            Collection<? extends TransactionManager> tms = locator.getBeansOfType(TransactionManager.class);
+            if (tms.size() == 1) {
+                tm = tms.iterator().next();
+            }
+        }
+        return tm;
+    }
+
     private static void setReplyDestination(JMSConfiguration jmsConfig, JMSEndpoint endpoint) {
         if (endpoint.getReplyToName() != null)  {
             jmsConfig.setReplyDestination(endpoint.getReplyToName());
@@ -157,4 +187,18 @@ public final class JMSConfigFactory {
         }
         return env;
     }
+    
+    private static TransactionManager getTransactionManagerFromJndi(String transactionManagerJndiName) {
+        if (transactionManagerJndiName == null) {
+            return null;
+        }
+        try {
+            InitialContext ictx = new InitialContext();
+            return (TransactionManager)ictx.lookup(transactionManagerJndiName);
+        } catch (NamingException e) {
+            throw new IllegalArgumentException("Transaction Manager " + transactionManagerJndiName 
+                                               + " not found in jndi");
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
index f424ee5..f2d39c2 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
@@ -86,13 +86,15 @@ public class JMSConfiguration {
     private boolean useConduitIdSelector = true;
     private String conduitSelectorPrefix;
     private boolean jmsProviderTibcoEms;
-    
+
     private TransactionManager transactionManager;
 
     // For jms spec. Do not configure manually
     private String targetService;
     private String requestURI;
 
+
+
     public void ensureProperlyConfigured() {
         ConnectionFactory cf = getConnectionFactory();
         if (cf == null) {
@@ -302,6 +304,10 @@ public class JMSConfiguration {
         this.sessionTransacted = sessionTransacted;
     }
 
+    /**
+     * For compatibility with old spring based code
+     * @param transactionManager
+     */
     @Deprecated
     public void setTransactionManager(Object transactionManager) {
     }
@@ -431,11 +437,11 @@ public class JMSConfiguration {
     }
 
     public TransactionManager getTransactionManager() {
-        return transactionManager;
+        return this.transactionManager;
     }
 
     public void setTransactionManager(TransactionManager transactionManager) {
         this.transactionManager = transactionManager;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
index 34398c3..66eec97 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
@@ -39,6 +39,7 @@ import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.continuations.ContinuationProvider;
 import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.interceptor.OneWayProcessorInterceptor;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.security.SecurityContext;
@@ -218,22 +219,9 @@ public class JMSDestination extends AbstractMultiplexDestination implements Mess
             // handle the incoming message
             incomingObserver.onMessage(inMessage);
 
-            if (inMessage.getExchange() != null && inMessage.getExchange().getInMessage() != null) {
-                inMessage = inMessage.getExchange().getInMessage();
+            if (inMessage.getExchange() != null) {
+                processExceptions(inMessage.getExchange());
             }
-
-            // need to propagate any exceptions back so transactions can occur
-            if (inMessage.getContent(Exception.class) != null) {
-                Exception ex = inMessage.getContent(Exception.class);
-                if (!(ex instanceof org.apache.cxf.interceptor.Fault)) {
-                    if (ex.getCause() instanceof RuntimeException) {
-                        throw (RuntimeException)ex.getCause();
-                    } else {
-                        throw new RuntimeException(ex);
-                    }
-                }
-            }
-
         } catch (SuspendedInvocationException ex) {
             getLogger().log(Level.FINE, "Request message has been suspended");
         } catch (UnsupportedEncodingException ex) {
@@ -250,6 +238,30 @@ public class JMSDestination extends AbstractMultiplexDestination implements Mess
         }
     }
 
+    /**
+     * Rethrow exceptions for one way exchanges so the jms transaction can be rolled back.
+     * Do not roll back for request/reply as client might expect a response
+     */
+    private void processExceptions(Exchange exchange) {
+        if (!exchange.isOneWay()) {
+
+            return;
+        }
+        Message inMessage = exchange.getInMessage();
+        if (inMessage == null) {
+            return;
+        }
+        Exception ex = inMessage.getContent(Exception.class);
+
+        if (ex != null) {
+            if (ex.getCause() instanceof RuntimeException) {
+                throw (RuntimeException)ex.getCause();
+            } else {
+                throw new RuntimeException(ex);
+            }
+        }
+    }
+
     protected Logger getLogger() {
         return LOG;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
index 7929e0a..1b85ab3 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
@@ -86,6 +86,7 @@ public class JMSEndpoint {
     private boolean sessionTransacted;
     private String conduitIdSelectorPrefix;
     private boolean useConduitIdSelector = true;
+    private String jndiTransactionManagerName;
 
     /**
      * @param uri
@@ -409,6 +410,14 @@ public class JMSEndpoint {
     public void setUseConduitIdSelector(boolean useConduitIdSelector) {
         this.useConduitIdSelector = useConduitIdSelector;
     }
+    
+    public String getJndiTransactionManagerName() {
+        return jndiTransactionManagerName;
+    }
+
+    public void setJndiTransactionManagerName(String jndiTransactionManagerName) {
+        this.jndiTransactionManagerName = jndiTransactionManagerName;
+    }
 
     public enum DeliveryModeType { PERSISTENT, NON_PERSISTENT };
     
@@ -435,4 +444,5 @@ public class JMSEndpoint {
             throw new IllegalArgumentException(v);
         }
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
index fe2eeb8..1665f74 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
@@ -18,12 +18,17 @@
  */
 package org.apache.cxf.transport.jms.util;
 
+import java.util.Enumeration;
+
 import javax.jms.BytesMessage;
+import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
 import javax.jms.Session;
 
 import org.apache.cxf.transport.jms.JMSConstants;
@@ -95,5 +100,28 @@ public final class JMSUtil {
         return message;
     }
     
-
+    public static Queue createQueue(Connection connection, String name) throws JMSException {
+        Session session = null;
+        try {
+            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            return session.createQueue(name);
+        } finally {
+            session.close();
+        }
+    }
+    
+    public static int getNumMessages(Connection connection, Queue queue) throws JMSException {
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        QueueBrowser browser = session.createBrowser(queue);
+        @SuppressWarnings("unchecked")
+        Enumeration<Message> messages = browser.getEnumeration();
+        int actualNum = 0;
+        while (messages.hasMoreElements()) {
+            actualNum++;
+            messages.nextElement();
+        }
+        browser.close();
+        session.close();
+        return actualNum;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
index 1d81a7e..2a6ca01 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/PollingMessageListenerContainer.java
@@ -58,6 +58,7 @@ public class PollingMessageListenerContainer extends AbstractMessageListenerCont
                         transactionManager.begin();
                     }
                     Session session = closer.register(connection.createSession(transacted, acknowledgeMode));
+
                     MessageConsumer consumer = closer.register(session.createConsumer(destination,
                                                                                       messageSelector));
                     Message message = consumer.receive(1000);

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/ResourceCloser.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/ResourceCloser.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/ResourceCloser.java
index fa70cf5..da9a41d 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/ResourceCloser.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/ResourceCloser.java
@@ -45,6 +45,7 @@ public class ResourceCloser implements Closeable {
         for (Object resource : resources) {
             close(resource);
         }
+        resources.clear();
     }
     
     public void close(Object ...resources2) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConfigFactoryTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConfigFactoryTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConfigFactoryTest.java
index 02c41fa..1198b9e 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConfigFactoryTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSConfigFactoryTest.java
@@ -19,18 +19,64 @@
 
 package org.apache.cxf.transport.jms;
 
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.jms.uri.JMSEndpoint;
+import org.apache.cxf.transport.jms.uri.MyBeanLocator;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.junit.Assert;
 import org.junit.Test;
 
-
 public class JMSConfigFactoryTest extends AbstractJMSTester {
 
     @Test
     public void testUsernameAndPassword() throws Exception {
         EndpointInfo ei = setupServiceInfo("HelloWorldService", "HelloWorldPort");
         JMSConfiguration config = JMSConfigFactory.createFromEndpointInfo(bus, ei, target);
-        Assert.assertEquals("User name does not match." , "testUser", config.getUserName());
-        Assert.assertEquals("Password does not match." , "testPassword", config.getPassword());
+        Assert.assertEquals("User name does not match.", "testUser", config.getUserName());
+        Assert.assertEquals("Password does not match.", "testPassword", config.getPassword());
+    }
+
+    @Test
+    public void testTransactionManagerFromBus() throws XAException, NamingException {
+        Bus bus = BusFactory.newInstance().createBus();
+        ConfiguredBeanLocator cbl = bus.getExtension(ConfiguredBeanLocator.class);
+        MyBeanLocator mybl = new MyBeanLocator(cbl);
+        bus.setExtension(mybl, ConfiguredBeanLocator.class);
+
+        TransactionManager tmExpected = new GeronimoTransactionManager();
+        mybl.register("tm", tmExpected);
+        tmByName(bus, tmExpected);
+        tmByClass(bus, tmExpected);
+    }
+
+    private void tmByName(Bus bus, TransactionManager tmExpected) {
+        JMSEndpoint endpoint = new JMSEndpoint("jms:queue:Foo.Bar?jndiTransactionManagerName=tm");
+        Assert.assertEquals("tm", endpoint.getJndiTransactionManagerName());
+        JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpoint(bus, endpoint);
+        TransactionManager tm = jmsConfig.getTransactionManager();
+        Assert.assertEquals(tmExpected, tm);
+    }
+    
+    private void tmByClass(Bus bus, TransactionManager tmExpected) {
+        JMSEndpoint endpoint = new JMSEndpoint("jms:queue:Foo.Bar");
+        JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpoint(bus, endpoint);
+        TransactionManager tm = jmsConfig.getTransactionManager();
+        Assert.assertEquals(tmExpected, tm);
+    }
+
+
+    @Test
+    public void testTransactionManagerFromJndi() throws XAException, NamingException {
+        JMSEndpoint endpoint = 
+            new JMSEndpoint("jms:queue:Foo.Bar?jndiTransactionManagerName=java:/comp/TransactionManager");
+        Assert.assertEquals("java:/comp/TransactionManager", endpoint.getJndiTransactionManagerName());
+        // TODO Check JNDI lookup
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
index fe90601..b7f5041 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
@@ -186,4 +186,9 @@ public class JMSEndpointTest extends Assert {
         assertEquals(JMSEndpoint.QUEUE, endpoint.getJmsVariant());
     }
     
+    @Test
+    public void testTransactionManager() {
+        JMSEndpoint endpoint = new JMSEndpoint("jms:queue:Foo.Bar?jndiTransactionManagerName=test");
+        assertEquals("test", endpoint.getJndiTransactionManagerName());
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
index fa4d4ff..2c5a1b6 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
@@ -50,10 +50,11 @@ public class MyBeanLocator implements ConfiguredBeanLocator {
         List<T> result = new ArrayList<T>();
         for (String name : registry.keySet()) {
             Object bean = registry.get(name);
-            if (type == registry.get(name).getClass()) {
+            if (type.isAssignableFrom(bean.getClass())) {
                 result.add((T)bean);
             }
         }
+        result.addAll(cbl.getBeansOfType(type));
         return result;
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
index a474810..2484277 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
@@ -18,8 +18,6 @@
  */
 package org.apache.cxf.transport.jms.util;
 
-import java.util.Enumeration;
-
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
@@ -28,7 +26,6 @@ import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
-import javax.jms.QueueBrowser;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.transaction.TransactionManager;
@@ -38,7 +35,7 @@ import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.ActiveMQXAConnectionFactory;
 import org.apache.activemq.RedeliveryPolicy;
 import org.apache.activemq.pool.XaPooledConnectionFactory;
-import org.apache.aries.transaction.internal.AriesTransactionManagerImpl;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -50,9 +47,9 @@ public class MessageListenerTest {
 
     @Test
     public void testWithJTA() throws JMSException, XAException, InterruptedException {
-        TransactionManager transactionManager = new AriesTransactionManagerImpl();
+        TransactionManager transactionManager = new GeronimoTransactionManager();
         Connection connection = createXAConnection("brokerJTA", transactionManager);
-        Queue dest = createQueue(connection, "test");
+        Queue dest = JMSUtil.createQueue(connection, "test");
 
         MessageListener listenerHandler = new TestMessageListener();
         PollingMessageListenerContainer container = new PollingMessageListenerContainer(connection, dest,
@@ -72,7 +69,7 @@ public class MessageListenerTest {
     @Test
     public void testNoTransaction() throws JMSException, XAException, InterruptedException {
         Connection connection = createConnection("brokerNoTransaction");
-        Queue dest = createQueue(connection, "test");
+        Queue dest = JMSUtil.createQueue(connection, "test");
 
         MessageListener listenerHandler = new TestMessageListener();
         AbstractMessageListenerContainer container = new MessageListenerContainer(connection, dest,
@@ -97,7 +94,7 @@ public class MessageListenerTest {
     @Test
     public void testLocalTransaction() throws JMSException, XAException, InterruptedException {
         Connection connection = createConnection("brokerLocalTransaction");
-        Queue dest = createQueue(connection, "test");
+        Queue dest = JMSUtil.createQueue(connection, "test");
         MessageListener listenerHandler = new TestMessageListener();
         AbstractMessageListenerContainer container = new MessageListenerContainer(connection, dest, listenerHandler);
         container.setTransacted(true);
@@ -111,7 +108,7 @@ public class MessageListenerTest {
 
     private void testTransactionalBehaviour(Connection connection, Queue dest) throws JMSException,
         InterruptedException {
-        Queue dlq = createQueue(connection, "ActiveMQ.DLQ");
+        Queue dlq = JMSUtil.createQueue(connection, "ActiveMQ.DLQ");
         assertNumMessagesInQueue("At the start the queue should be empty", connection, dest, 0, 0);
         assertNumMessagesInQueue("At the start the DLQ should be empty", connection, dlq, 0, 0);
 
@@ -170,7 +167,7 @@ public class MessageListenerTest {
         long startTime = System.currentTimeMillis();
         int actualNum;
         do {
-            actualNum = getNumMessages(connection, queue);
+            actualNum = JMSUtil.getNumMessages(connection, queue);
             
             //System.out.println("Messages in queue " + queue.getQueueName() + ": " + actualNum
             //                   + ", expecting: " + expectedNum);
@@ -179,21 +176,6 @@ public class MessageListenerTest {
         Assert.assertEquals(message + " -> number of messages", expectedNum, actualNum);
     }
 
-    private int getNumMessages(Connection connection, Queue queue) throws JMSException {
-        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        QueueBrowser browser = session.createBrowser(queue);
-        @SuppressWarnings("unchecked")
-        Enumeration<Message> messages = browser.getEnumeration();
-        int actualNum = 0;
-        while (messages.hasMoreElements()) {
-            actualNum++;
-            messages.nextElement();
-        }
-        browser.close();
-        session.close();
-        return actualNum;
-    }
-
     private void sendMessage(Connection connection, Destination dest, String content) throws JMSException,
         InterruptedException {
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -205,16 +187,6 @@ public class MessageListenerTest {
         Thread.sleep(500); // Give receiver some time to process
     }
 
-    private Queue createQueue(Connection connection, String name) throws JMSException {
-        Session session = null;
-        try {
-            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            return session.createQueue(name);
-        } finally {
-            session.close();
-        }
-    }
-
     private static final class TestMessageListener implements MessageListener {
         @Override
         public void onMessage(Message message) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/pom.xml
----------------------------------------------------------------------
diff --git a/systests/transport-jms/pom.xml b/systests/transport-jms/pom.xml
index 1d1e83b..99b6db1 100644
--- a/systests/transport-jms/pom.xml
+++ b/systests/transport-jms/pom.xml
@@ -306,5 +306,11 @@
             <artifactId>commons-httpclient</artifactId>
             <scope>test</scope>
         </dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.components</groupId>
+			<artifactId>geronimo-transaction</artifactId>
+			<version>3.1.1</version>
+			<scope>test</scope>
+		</dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/AbstractVmJMSTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/AbstractVmJMSTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/AbstractVmJMSTest.java
index 46d5d10..4fb21dd 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/AbstractVmJMSTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/AbstractVmJMSTest.java
@@ -19,7 +19,7 @@
 package org.apache.cxf.systest.jms;
 
 import java.io.Closeable;
-import java.io.IOException;
+import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -28,13 +28,14 @@ import javax.jms.ConnectionFactory;
 import javax.xml.ws.Endpoint;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.RedeliveryPolicy;
+import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxws.EndpointImpl;
-import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
 import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
-
 import org.junit.After;
 import org.junit.AfterClass;
 
@@ -50,20 +51,47 @@ public abstract class AbstractVmJMSTest {
     protected static Bus bus;
     protected static ConnectionFactoryFeature cff;
     protected static ConnectionFactory cf;
-    protected static EmbeddedJMSBrokerLauncher broker;
+    protected static BrokerService broker;
     private List<Object> closeableResources = new ArrayList<Object>();
 
     public static void startBusAndJMS(Class<?> testClass) {
-        bus = BusFactory.getDefaultBus();
         String brokerURI = "vm://" + testClass.getName() + "?broker.persistent=false&broker.useJmx=false";
-        broker = new EmbeddedJMSBrokerLauncher(brokerURI);
-        broker.setBrokerName(testClass.getName());
-        broker.run();
+        startBusAndJMS(brokerURI);
+        startBroker(brokerURI);
+    }
+    
+    public static void startBusAndJMS(String brokerURI) {
+        bus = BusFactory.getDefaultBus();
         ActiveMQConnectionFactory cf1 = new ActiveMQConnectionFactory(brokerURI);
+        RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
+        redeliveryPolicy.setMaximumRedeliveries(1);
+        redeliveryPolicy.setInitialRedeliveryDelay(1000);
+        cf1.setRedeliveryPolicy(redeliveryPolicy());
         cf = new PooledConnectionFactory(cf1);
         cff = new ConnectionFactoryFeature(cf);
     }
     
+    protected static RedeliveryPolicy redeliveryPolicy() {
+        RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
+        redeliveryPolicy.setMaximumRedeliveries(1);
+        redeliveryPolicy.setInitialRedeliveryDelay(1000);
+        return redeliveryPolicy;
+    }
+
+    public static void startBroker(String brokerURI) {
+        broker = new BrokerService();
+        broker.setPersistent(false);
+        try {
+            broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
+            broker.setTmpDataDirectory(new File("./target"));
+            broker.setUseJmx(false);
+            broker.addConnector(brokerURI);
+            broker.start();
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+    
     public <T> T markForClose(T resource) {
         closeableResources.add(resource);
         return resource;
@@ -75,7 +103,7 @@ public abstract class AbstractVmJMSTest {
             if (proxy instanceof Closeable) {
                 try {
                     ((Closeable)proxy).close();
-                } catch (IOException e) {
+                } catch (Exception e) {
                     // Ignore
                 }
             }
@@ -89,8 +117,10 @@ public abstract class AbstractVmJMSTest {
         bus = null;
         cf = null;
         cff = null;
-        broker.stop();
-        broker = null;
+        if (broker != null) {
+            broker.stop();
+            broker = null;
+        }
     }
     
     public URL getWSDLURL(String s) throws Exception {

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
index 8e1af76..973985b 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
@@ -62,14 +62,12 @@ import org.apache.hello_world_doc_lit.Greeter;
 import org.apache.hello_world_doc_lit.PingMeFault;
 import org.apache.hello_world_doc_lit.SOAPService2;
 import org.apache.hello_world_doc_lit.SOAPService7;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
-
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class JMSClientServerTest extends AbstractBusClientServerTestBase {

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HWSoapMessageDocProvider.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HWSoapMessageDocProvider.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HWSoapMessageDocProvider.java
index 974667e..e045300 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HWSoapMessageDocProvider.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/HWSoapMessageDocProvider.java
@@ -40,8 +40,6 @@ import org.apache.cxf.continuations.Continuation;
 import org.apache.cxf.continuations.ContinuationProvider;
 import org.apache.cxf.helpers.DOMUtils;
 
-
-
 @WebServiceProvider(serviceName = "HelloWorldService", 
             portName = "HelloWorldPort",
             targetNamespace = "http://cxf.apache.org/hello_world_jms",

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
index fc8553c..f469589 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/shared/JMSSharedQueueTest.java
@@ -39,7 +39,6 @@ import org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStati
 import org.apache.cxf.systest.jms.AbstractVmJMSTest;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transport.jms.JMSMessageHeadersType;
-
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
index e2a16a2..0a45a1d 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/GreeterImplWithTransaction.java
@@ -18,48 +18,53 @@
  */
 package org.apache.cxf.systest.jms.tx;
 
-import java.util.concurrent.atomic.AtomicBoolean;
-
 import javax.jws.WebService;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
 
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.hello_world_doc_lit.Greeter;
 import org.apache.hello_world_doc_lit.PingMeFault;
+import org.junit.Assert;
 
+/**
+ * Service that throws an exception when called by BAD_GUY
+ */
 @WebService(endpointInterface = "org.apache.hello_world_doc_lit.Greeter")
 public class GreeterImplWithTransaction implements Greeter {
-    private AtomicBoolean flag = new AtomicBoolean(true);
-       
-    public String greetMe(String requestType) {
-        System.out.println("Reached here :" + requestType);
-        if ("Bad guy".equals(requestType)) {
-            if (flag.getAndSet(false)) {
-                //System.out.println("Throw exception here :" + requestType);
-                throw new RuntimeException("Got a bad guy call for greetMe");
-            } else {
-                requestType = "[Bad guy]";
-                flag.set(true);
-            }
+    public static final String BAD_GUY = "Bad guy";
+    public static final String GOOD_GUY = "Good guy";
+    
+    public String greetMe(String name) {
+        if (BAD_GUY.equals(name)) {
+            throw new RuntimeException("Got a bad guy call for greetMe");
         }
-        return "Hello " + requestType;
+        return "Hello " + name;
     }
 
     @Override
     public void greetMeOneWay(String name) {
-        if ("Bad guy".equals(name)) {
+        ConfiguredBeanLocator locator = BusFactory.getDefaultBus().getExtension(ConfiguredBeanLocator.class);
+        TransactionManager tm = locator.getBeansOfType(TransactionManager.class).iterator().next();
+        try {
+            Assert.assertNotNull("We should run inside a transaction", tm.getTransaction());
+        } catch (SystemException e) {
+            throw new RuntimeException(e.getMessage(), e); 
+        } 
+        if (BAD_GUY.equals(name)) {
             throw new RuntimeException("Got a bad guy call for greetMe");
         }
     }
 
     @Override
     public void pingMe() throws PingMeFault {
-        // TODO Auto-generated method stub
-        
+        throw new IllegalArgumentException("Not implemented");
     }
 
     @Override
     public String sayHi() {
-        // TODO Auto-generated method stub
-        return null;
+        throw new IllegalArgumentException("Not implemented");
     }
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
deleted file mode 100644
index 1b262e8..0000000
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.systest.jms.tx;
-
-import java.util.Collections;
-
-import org.apache.cxf.jaxws.EndpointImpl;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.systest.jms.AbstractVmJMSTest;
-import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
-import org.apache.hello_world_doc_lit.Greeter;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class JMSTransactionClientServerTest extends AbstractVmJMSTest {
-    private static final String SERVICE_ADDRESS = 
-        "jms:queue:greeter.queue.tx?receivetTimeOut=5000&sessionTransacted=true";
-    private static EndpointImpl endpoint;
-
-    @BeforeClass
-    public static void startServers() throws Exception {
-        startBusAndJMS(JMSTransactionClientServerTest.class);
-
-        endpoint = new EndpointImpl(bus, new GreeterImplWithTransaction());
-        endpoint.setAddress(SERVICE_ADDRESS);
-        endpoint.setFeatures(Collections.singletonList(cff));
-        endpoint.publish();
-    }
-
-    @AfterClass
-    public static void clearProperty() {
-        endpoint.stop();
-    }
-
-    @Test
-    public void testTransaction() throws Exception {
-        Greeter greeter = createGreeterProxy();
-        // Should be processed normally
-        greeter.greetMeOneWay("Good guy");
-        
-        // Should cause rollback, redelivery and in the end the message should go to the dead letter queue
-        greeter.greetMe("Bad guy");
-    }
-
-    private Greeter createGreeterProxy() throws Exception {
-        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
-        factory.setBus(bus);
-        factory.getFeatures().add(cff);
-        factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
-        factory.setServiceClass(Greeter.class);
-        factory.setAddress(SERVICE_ADDRESS);
-        return (Greeter)markForClose(factory.create());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionTest.java
new file mode 100644
index 0000000..8dfd5e0
--- /dev/null
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionTest.java
@@ -0,0 +1,165 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jms.tx;
+
+import java.util.Collections;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+
+import org.apache.activemq.ActiveMQXAConnectionFactory;
+import org.apache.activemq.jms.pool.JcaPooledConnectionFactory;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.systest.jms.AbstractVmJMSTest;
+import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
+import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+import org.apache.cxf.transport.jms.util.JMSUtil;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.hello_world_doc_lit.Greeter;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JMSTransactionTest extends AbstractVmJMSTest {
+    private static final String SERVICE_ADDRESS = 
+        "jms:queue:greeter.queue.tx?receivetTimeOut=5000&sessionTransacted=true";
+    private static EndpointImpl endpoint;
+    private static TransactionManager transactionManager;
+
+    public static void startBusAndJMS(Class<?> testClass) {
+        String brokerURI = "vm://" + testClass.getName() + "?broker.persistent=false&broker.useJmx=false";
+        startBusAndJMS(brokerURI);
+        startBroker(brokerURI);
+    }
+    
+    public static void startBusAndJMS(String brokerURI) {
+        try {
+            transactionManager = new GeronimoTransactionManager();
+        } catch (XAException e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+        bus = BusFactory.getDefaultBus();
+        registerTransactionManager();
+        ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory(brokerURI);
+        cf1.setRedeliveryPolicy(redeliveryPolicy());
+        JcaPooledConnectionFactory pcf = new JcaPooledConnectionFactory();
+        pcf.setTransactionManager(transactionManager);
+        pcf.setConnectionFactory(cf1);
+        cf = pcf;
+        cff = new ConnectionFactoryFeature(pcf);
+    }
+
+    /**
+     * For real world scenarios create a bean for the transaction manager in blueprint or spring
+     */
+    private static void registerTransactionManager() {
+        ConfiguredBeanLocator cbl = bus.getExtension(ConfiguredBeanLocator.class);
+        MyBeanLocator mybl = new MyBeanLocator(cbl);
+        mybl.register("tm", transactionManager);
+        bus.setExtension(mybl, ConfiguredBeanLocator.class);
+    }
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        startBusAndJMS(JMSTransactionTest.class);
+        //startBusAndJMS("tcp://localhost:61616");
+
+        endpoint = new EndpointImpl(bus, new GreeterImplWithTransaction());
+        endpoint.setAddress(SERVICE_ADDRESS);
+        endpoint.setFeatures(Collections.singletonList(cff));
+        endpoint.publish();
+    }
+
+    @AfterClass
+    public static void clearProperty() {
+        endpoint.stop();
+    }
+
+    /**
+     * Request reply should not cause roll backs
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testNoTransactionRequestReply() throws Exception {
+        Greeter greeter = markForClose(createGreeterProxy());
+
+        greeter.greetMe("Good guy");
+        try {
+            greeter.greetMe("Bad guy");
+            Assert.fail("Expecting exception here");
+        } catch (Exception e) {
+            // Fine
+        }
+    }
+    
+    @Test
+    public void testTransactionOneWay() throws Exception {
+        Connection conn = cf.createConnection();
+        conn.start();
+        Queue queue = JMSUtil.createQueue(conn, "ActiveMQ.DLQ");
+        assertNumMessagesInQueue("DLQ should be empty", conn, queue, 0, 1000);
+        
+        Greeter greeter = markForClose(createGreeterProxy());
+        // Should be processed normally
+        greeter.greetMeOneWay(GreeterImplWithTransaction.GOOD_GUY);
+        
+        
+        assertNumMessagesInQueue("DLQ should be empty", conn, queue, 0, 1000);
+
+        // Should cause rollback, redelivery and in the end the message should go to the dead letter queue
+        greeter.greetMeOneWay(GreeterImplWithTransaction.BAD_GUY);
+        
+        assertNumMessagesInQueue("Request should be put into DLQ", conn, queue, 1, 2000);
+        conn.close();
+    }
+
+    private Greeter createGreeterProxy() throws Exception {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setBus(bus);
+        factory.getFeatures().add(cff);
+        factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
+        factory.setServiceClass(Greeter.class);
+        factory.setAddress(SERVICE_ADDRESS);
+        return (Greeter)markForClose(factory.create());
+    }
+    
+    private void assertNumMessagesInQueue(String message, Connection connection, Queue queue,
+                                          int expectedNum, int timeout) throws JMSException,
+        InterruptedException {
+        long startTime = System.currentTimeMillis();
+        int actualNum;
+        do {
+            actualNum = JMSUtil.getNumMessages(connection, queue);
+            
+            //System.out.println("Messages in queue " + queue.getQueueName() + ": " + actualNum
+            //                   + ", expecting: " + expectedNum);
+            Thread.sleep(100);
+        } while ((System.currentTimeMillis() - startTime < timeout) && expectedNum != actualNum);
+        Assert.assertEquals(message + " -> number of messages", expectedNum, actualNum);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/MyBeanLocator.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/MyBeanLocator.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/MyBeanLocator.java
new file mode 100644
index 0000000..c33fbf4
--- /dev/null
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/MyBeanLocator.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jms.tx;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+
+public class MyBeanLocator implements ConfiguredBeanLocator {
+    ConfiguredBeanLocator cbl;
+    Map<String, Object> registry = new HashMap<String, Object>();
+    
+    public MyBeanLocator(ConfiguredBeanLocator cbl) {
+        this.cbl = cbl;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T getBeanOfType(String name, Class<T> type) {
+        if (registry.containsKey(name)) {
+            return (T)registry.get(name);
+        } else {
+            return cbl.getBeanOfType(name, type);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
+        List<T> result = new ArrayList<T>();
+        for (String name : registry.keySet()) {
+            Object bean = registry.get(name);
+            if (type.isAssignableFrom(bean.getClass())) {
+                result.add((T)bean);
+            }
+        }
+        result.addAll(cbl.getBeansOfType(type));
+        return result;
+    }
+
+    public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
+        return cbl.loadBeansOfType(type, listener);
+    
+    }
+    public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
+        return cbl.hasConfiguredPropertyValue(beanName, propertyName, value);
+    }
+    
+    public List<String> getBeanNamesOfType(Class<?> type) {
+        return cbl.getBeanNamesOfType(type);
+    }
+    public boolean hasBeanOfName(String name) {
+        return cbl.hasBeanOfName(name);
+    }
+
+    public void register(String name, Object object) {
+        registry.put(name, object);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/642cf8dd/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml
deleted file mode 100644
index 68c2a2f..0000000
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/jms_server_config.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
- 
-  http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied. See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ct="http://cxf.apache.org/configuration/types" xmlns:jms="http://cxf.apache.org/transports/jms" xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
-    <import resource="classpath:META-INF/cxf/cxf.xml"/>
-    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
-    <jaxws:endpoint xmlns:s="http://apache.org/hello_world_doc_lit" 
-    	implementor="#implementor" 
-    	implementorClass="org.apache.hello_world_doc_lit.Greeter" 
-    	wsdlLocation="testutils/hello_world_doc_lit.wsdl" 
-    	serviceName="s:SOAPService2" 
-    	endpointName="s:SoapPort2"/>
-    <bean id="ConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
-        <constructor-arg value="${EmbeddedBrokerURL}"/>
-    </bean>
-    <bean id="implementor" class="org.apache.cxf.systest.jms.tx.GreeterImplWithTransaction"/>
-</beans>


Mime
View raw message