Index: src/test/java/org/codehaus/stomp/StompTest.java
===================================================================
--- src/test/java/org/codehaus/stomp/StompTest.java	(revision 90)
+++ src/test/java/org/codehaus/stomp/StompTest.java	(working copy)
@@ -695,7 +695,7 @@
     //-------------------------------------------------------------------------
     protected void setUp() throws Exception {
         connectionFactory = createConnectionFactory();
-        stompConnect = new StompConnect(connectionFactory);
+//        stompConnect = new StompConnect(connectionFactory);
         stompConnect.setUri("tcp://localhost:" + port);
         stompConnect.start();
 
Index: src/test/java/org/codehaus/stomp/ActiveMQStompConnect.java
===================================================================
--- src/test/java/org/codehaus/stomp/ActiveMQStompConnect.java	(revision 90)
+++ src/test/java/org/codehaus/stomp/ActiveMQStompConnect.java	(working copy)
@@ -33,7 +33,7 @@
             if (args.length > 0) {
                 url = args[0];
             }
-            connect.setConnectionFactory(new ActiveMQConnectionFactory(url));
+//            connect.setConnectionFactory(new ActiveMQConnectionFactory(url));
             connect.start();
             connect.join();
         }
Index: src/main/java/org/codehaus/stomp/tcp/TcpTransport.java
===================================================================
--- src/main/java/org/codehaus/stomp/tcp/TcpTransport.java	(revision 90)
+++ src/main/java/org/codehaus/stomp/tcp/TcpTransport.java	(working copy)
@@ -42,7 +42,7 @@
 import java.util.Map;
 
 /**
- * @version $Revision: $
+ * @version $Revision$
  */
 public class TcpTransport extends ServiceSupport implements Runnable, StompHandler {
     private static final Log log = LogFactory.getLog(TcpTransport.class);
@@ -99,7 +99,9 @@
     /**
      * A one way asynchronous send
      */
-    public void onStompFrame(StompFrame command) throws Exception {
+    // PATCHED BY TOM - THIS CAN BE INVOKED BY THE RECEIPT FOR A SUBSCRIPTION AT THE SAME
+    // TIME AS THE FIRST MESSAGE IS RECEIVED
+    public synchronized void onStompFrame(StompFrame command) throws Exception {
         checkStarted();
         marshaller.marshal(command, dataOut);
         dataOut.flush();
@@ -391,10 +393,10 @@
     }
 
     protected void initializeStreams() throws Exception {
-        TcpBufferedInputStream buffIn = new TcpBufferedInputStream(socket.getInputStream(), ioBufferSize);
-        this.dataIn = new DataInputStream(buffIn);
-        TcpBufferedOutputStream buffOut = new TcpBufferedOutputStream(socket.getOutputStream(), ioBufferSize);
-        this.dataOut = new DataOutputStream(buffOut);
+//        TcpBufferedInputStream buffIn = new TcpBufferedInputStream(socket.getInputStream(), ioBufferSize);
+        this.dataIn = new DataInputStream(socket.getInputStream());//new DataInputStream(buffIn);
+  //      TcpBufferedOutputStream buffOut = new TcpBufferedOutputStream(socket.getOutputStream(), ioBufferSize);
+        this.dataOut = new DataOutputStream(socket.getOutputStream());//new DataOutputStream(buffOut);
     }
 
     protected void closeStreams() throws IOException {
Index: src/main/java/org/codehaus/stomp/jms/StompSession.java
===================================================================
--- src/main/java/org/codehaus/stomp/jms/StompSession.java	(revision 90)
+++ src/main/java/org/codehaus/stomp/jms/StompSession.java	(working copy)
@@ -17,6 +17,8 @@
  */
 package org.codehaus.stomp.jms;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.codehaus.stomp.ProtocolException;
 import org.codehaus.stomp.Stomp;
 import org.codehaus.stomp.StompFrame;
@@ -27,6 +29,8 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Represents a logical session (a parallel unit of work) within a Stomp connection
@@ -37,7 +41,9 @@
     private final ProtocolConverter protocolConverter;
     private final Session session;
     private MessageProducer producer;
-    private Map<String, Destination> temporaryDestinations = new HashMap<String, Destination>();
+    private static Map<String, Destination> temporaryDestinations = new HashMap<String, Destination>();
+    private List<String> created = new ArrayList<String>();
+    private static final Log log = LogFactory.getLog(StompSession.class);
 
     public StompSession(ProtocolConverter protocolConverter, Session session) {
         this.protocolConverter = protocolConverter;
@@ -61,14 +67,20 @@
 
     public void close() throws JMSException {
         session.close();
+	synchronized (temporaryDestinations) {
+		Iterator<String> i = created.iterator();
+		while (i.hasNext()) {
+			temporaryDestinations.remove(i.next());
+		}
+	}
     }
 
     public void sendToJms(StompFrame command) throws JMSException, ProtocolException {
         Map headers = command.getHeaders();
         String destinationName = (String) headers.remove(Stomp.Headers.Send.DESTINATION);
         Message message = convertFrame(command);
+        Destination destination = convertDestination(destinationName, false);
 
-        Destination destination = convertDestination(destinationName);
 
         int deliveryMode = getDeliveryMode(headers);
         int priority = getPriority(headers);
@@ -78,12 +90,13 @@
     }
 
     public void sendToStomp(Message message, StompSubscription subscription) throws Exception {
+    	log.debug("Sending to stomp");
         StompFrame frame = convertMessage(message);
         frame.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, subscription.getSubscriptionId());
         protocolConverter.sendToStomp(frame);
     }
 
-    public Destination convertDestination(String name) throws ProtocolException, JMSException {
+    public Destination convertDestination(String name, boolean forceNew) throws ProtocolException, JMSException {
         if (name == null) {
             throw new ProtocolException("No destination is specified!");
         }
@@ -97,11 +110,22 @@
         }
         else if (name.startsWith("/temp-queue/")) {
             String tempName = name.substring("/temp-queue/".length(), name.length());
-            return temporaryDestination(tempName, session.createTemporaryQueue());
+	    Destination answer = temporaryDestinations.get(tempName);
+
+            if (forceNew || answer == null) {
+	            return temporaryDestination(tempName, session.createTemporaryQueue());
+	    } else {
+		    return answer;
+	    }
         }
         else if (name.startsWith("/temp-topic/")) {
             String tempName = name.substring("/temp-topic/".length(), name.length());
-            return temporaryDestination(tempName, session.createTemporaryTopic());
+            Destination answer = temporaryDestinations.get(tempName);
+            if (forceNew || answer == null) {
+	            return temporaryDestination(tempName, session.createTemporaryTopic());
+	    } else {
+		    return answer;
+	    }
         }
         else {
             throw new ProtocolException("Illegal destination name: [" + name + "] -- StompConnect destinations " +
@@ -118,6 +142,7 @@
             Topic topic = (Topic) d;
             if (d instanceof TemporaryTopic) {
                 buffer.append("/temp-topic/");
+                temporaryDestination(topic.getTopicName(), d);
             }
             else {
                 buffer.append("/topic/");
@@ -128,6 +153,7 @@
             Queue queue = (Queue) d;
             if (d instanceof TemporaryQueue) {
                 buffer.append("/temp-queue/");
+                temporaryDestination(queue.getQueueName(), d);
             }
             else {
                 buffer.append("/queue/");
@@ -139,13 +165,12 @@
 
 
     protected synchronized Destination temporaryDestination(String tempName, Destination temporaryDestination) {
-        Destination answer = temporaryDestinations.get(tempName);
-        if (answer == null) {
-            temporaryDestinations.put(tempName, temporaryDestination);
-            answer = temporaryDestination;
-        }
-        return answer;
-    }
+		synchronized (temporaryDestinations) {
+			temporaryDestinations.put(tempName, temporaryDestination);
+			created.add(tempName);
+		}
+		return temporaryDestination;
+	}
 
     protected int getDeliveryMode(Map headers) throws JMSException {
         Object o = headers.remove(Stomp.Headers.Send.PERSISTENT);
@@ -223,7 +248,7 @@
 
         o = headers.remove(Stomp.Headers.Send.REPLY_TO);
         if (o != null) {
-            msg.setJMSReplyTo(convertDestination((String) o));
+            msg.setJMSReplyTo(convertDestination((String) o, false));
         }
 
         // now the general headers
Index: src/main/java/org/codehaus/stomp/jms/StompSubscription.java
===================================================================
--- src/main/java/org/codehaus/stomp/jms/StompSubscription.java	(revision 90)
+++ src/main/java/org/codehaus/stomp/jms/StompSubscription.java	(working copy)
@@ -53,7 +53,7 @@
         Map headers = frame.getHeaders();
         String selector = (String) headers.remove(Stomp.Headers.Subscribe.SELECTOR);
         String destinationName = (String) headers.get(Stomp.Headers.Subscribe.DESTINATION);
-        destination = session.convertDestination(destinationName);
+        destination = session.convertDestination(destinationName, true);
         Session jmsSession = session.getSession();
         boolean noLocal = false;
 
@@ -82,14 +82,19 @@
     }
 
     public void onMessage(Message message) {
+    	log.debug("onMessage3");
         try {
             int ackMode = session.getSession().getAcknowledgeMode();
-            if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
-                synchronized (this) {
-                    session.getProtocolConverter().addMessageToAck(message);
-                }
-            }
-            session.sendToStomp(message, this);
+			if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
+				synchronized (consumer) {
+					boolean closing = session.getProtocolConverter()
+							.addMessageToAck(message, consumer);
+					if (!closing) {
+						session.sendToStomp(message, this);
+						consumer.wait();
+					}
+				}
+			}
         }
         catch (Exception e) {
             log.error("Failed to process message due to: " + e + ". Message: " + message, e);
Index: src/main/java/org/codehaus/stomp/jms/ProtocolConverter.java
===================================================================
--- src/main/java/org/codehaus/stomp/jms/ProtocolConverter.java	(revision 90)
+++ src/main/java/org/codehaus/stomp/jms/ProtocolConverter.java	(working copy)
@@ -17,6 +17,29 @@
  */
 package org.codehaus.stomp.jms;
 
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.naming.InitialContext;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.codehaus.stomp.ProtocolException;
@@ -25,452 +48,550 @@
 import org.codehaus.stomp.StompFrameError;
 import org.codehaus.stomp.StompHandler;
 import org.codehaus.stomp.util.IntrospectionSupport;
+import org.jboss.blacktie.tx.JtsTransactionImple;
 
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.concurrent.ConcurrentHashMap;
-
 /**
  * A protocol switch between JMS and Stomp
- *
+ * 
  * @author <a href="http://people.apache.org/~jstrachan/">James Strachan</a>
  * @author <a href="http://hiramchirino.com">chirino</a>
  */
 public class ProtocolConverter implements StompHandler {
-    private static final transient Log log = LogFactory.getLog(ProtocolConverter.class);
-    private ConnectionFactory connectionFactory;
-    private final StompHandler outputHandler;
-    private Connection connection;
-    private StompSession defaultSession;
-    private StompSession clientAckSession;
-    private final Map<String,StompSession> transactedSessions = new ConcurrentHashMap<String,StompSession>();
-    private final Map subscriptions = new ConcurrentHashMap();
-    private final Map messages = new ConcurrentHashMap();
+	private static final transient Log log = LogFactory
+			.getLog(ProtocolConverter.class);
+	private XAConnectionFactory connectionFactory;
+	private final StompHandler outputHandler;
+	private XAConnection connection;
+	private StompSession defaultSession;
+	private StompSession clientAckSession;
+	private final Map<String, StompSession> transactedSessions = new ConcurrentHashMap<String, StompSession>();
+	private final Map subscriptions = new ConcurrentHashMap();
+	private final Map messages = new ConcurrentHashMap();
+	private volatile boolean closing;
+	private StompSession xaSession;
 
-    public ProtocolConverter(ConnectionFactory connectionFactory, StompHandler outputHandler) {
-        this.connectionFactory = connectionFactory;
-        this.outputHandler = outputHandler;
-    }
+	public ProtocolConverter(XAConnectionFactory connectionFactory,
+			StompHandler outputHandler) {
+		this.connectionFactory = connectionFactory;
+		this.outputHandler = outputHandler;
+	}
 
-    public ConnectionFactory getConnectionFactory() {
-        return connectionFactory;
-    }
+	public XAConnectionFactory getConnectionFactory() {
+		return connectionFactory;
+	}
 
-    public StompHandler getOutputHandler() {
-        return outputHandler;
-    }
+	public StompHandler getOutputHandler() {
+		return outputHandler;
+	}
 
-    public synchronized void close() throws JMSException {
-        try {
-            // lets close all the sessions first
-            JMSException firstException = null;
-            Collection<StompSession> sessions = new ArrayList<StompSession>(transactedSessions.values());
-            if (defaultSession != null) {
-                sessions.add(defaultSession);
-            }
-            if (clientAckSession != null) {
-                sessions.add(clientAckSession);
-            }
-            for (StompSession session : sessions) {
-                try {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Closing session: " + session + " with ack mode: " + session.getSession().getAcknowledgeMode());
-                    }
-                    session.close();
-                }
-                catch (JMSException e) {
-                    if (firstException == null) {                                           
-                        firstException = e;
-                    }
-                }
-            }
+	public synchronized void close() throws JMSException {
+		closing = true;
+		try {
+			// PATCHED BY TOM FOR SINGLE MESSAGE DELIVERY
+			Iterator iterator = messages.values().iterator();
+			while (iterator.hasNext()) {
+				MSC msc = (MSC) iterator.next();
+				synchronized (msc.consumer) {
+					msc.consumer.setMessageListener(null);
+					msc.consumer.notify();
+				}
+			}
 
-            // now the connetion
-            if (connection != null) {
-                connection.close();
-            }
+			// lets close all the sessions first
+			JMSException firstException = null;
+			Collection<StompSession> sessions = new ArrayList<StompSession>(
+					transactedSessions.values());
+			if (defaultSession != null) {
+				sessions.add(defaultSession);
+			}
 
-            if (firstException != null) {
-                throw firstException;
-            }
-        }
-        finally {
-            connection = null;
-            defaultSession = null;
-            clientAckSession = null;
-            transactedSessions.clear();
-            subscriptions.clear();
-            messages.clear();
-        }
-    }
+			if (xaSession != null) {
+				sessions.add(xaSession);
+			}
+			if (clientAckSession != null) {
+				sessions.add(clientAckSession);
+			}
+			for (StompSession session : sessions) {
+				try {
+					if (log.isDebugEnabled()) {
+						log.debug("Closing session: " + session
+								+ " with ack mode: "
+								+ session.getSession().getAcknowledgeMode());
+					}
+					session.close();
+					log.error("Closing session");
+					new RuntimeException().printStackTrace();
+				} catch (JMSException e) {
+					if (firstException == null) {
+						firstException = e;
+					}
+				}
+			}
 
-    /**
-     * Process a Stomp Frame
-     */
-    public void onStompFrame(StompFrame command) throws Exception {
-        try {
-            if (log.isDebugEnabled()) {
-                log.debug(">>>> " + command.getAction() + " headers: " + command.getHeaders());
-            }
-            
-            if (command.getClass() == StompFrameError.class) {
-                throw ((StompFrameError) command).getException();
-            }
+			// now the connetion
+			if (connection != null) {
+				connection.close();
+			}
 
-            String action = command.getAction();
-            if (action.startsWith(Stomp.Commands.SEND)) {
-                onStompSend(command);
-            }
-            else if (action.startsWith(Stomp.Commands.ACK)) {
-                onStompAck(command);
-            }
-            else if (action.startsWith(Stomp.Commands.BEGIN)) {
-                onStompBegin(command);
-            }
-            else if (action.startsWith(Stomp.Commands.COMMIT)) {
-                onStompCommit(command);
-            }
-            else if (action.startsWith(Stomp.Commands.ABORT)) {
-                onStompAbort(command);
-            }
-            else if (action.startsWith(Stomp.Commands.SUBSCRIBE)) {
-                onStompSubscribe(command);
-            }
-            else if (action.startsWith(Stomp.Commands.UNSUBSCRIBE)) {
-                onStompUnsubscribe(command);
-            }
-            else if (action.startsWith(Stomp.Commands.CONNECT)) {
-                onStompConnect(command);
-            }
-            else if (action.startsWith(Stomp.Commands.DISCONNECT)) {
-                onStompDisconnect(command);
-            }
-            else {
-                throw new ProtocolException("Unknown STOMP action: " + action);
-            }
-        }
-        catch (Exception e) {
+			if (firstException != null) {
+				throw firstException;
+			}
+		} finally {
+			connection = null;
+			defaultSession = null;
+			xaSession = null;
+			clientAckSession = null;
+			transactedSessions.clear();
+			subscriptions.clear();
+			messages.clear();
+		}
+	}
 
-            // Let the stomp client know about any protocol errors.
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos, "UTF-8"));
-            e.printStackTrace(stream);
-            stream.close();
+	/**
+	 * Process a Stomp Frame
+	 */
+	public void onStompFrame(StompFrame command) throws Exception {
+		try {
+			if (log.isDebugEnabled()) {
+				log.debug(">>>> " + command.getAction() + " headers: "
+						+ command.getHeaders());
+			}
 
-            HashMap headers = new HashMap();
-            headers.put(Stomp.Headers.Error.MESSAGE, e.getMessage());
+			if (command.getClass() == StompFrameError.class) {
+				throw ((StompFrameError) command).getException();
+			}
 
-            final String receiptId = (String) command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED);
-            if (receiptId != null) {
-                headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId);
-            }
+			String action = command.getAction();
+			if (action.startsWith(Stomp.Commands.SEND)) {
+				onStompSend(command);
+			} else if (action.startsWith(Stomp.Commands.ACK)) {
+				onStompAck(command);
+			} else if (action.startsWith(Stomp.Commands.BEGIN)) {
+				onStompBegin(command);
+			} else if (action.startsWith(Stomp.Commands.COMMIT)) {
+				onStompCommit(command);
+			} else if (action.startsWith(Stomp.Commands.ABORT)) {
+				onStompAbort(command);
+			} else if (action.startsWith(Stomp.Commands.SUBSCRIBE)) {
+				onStompSubscribe(command);
+			} else if (action.startsWith(Stomp.Commands.UNSUBSCRIBE)) {
+				onStompUnsubscribe(command);
+			} else if (action.startsWith(Stomp.Commands.CONNECT)) {
+				onStompConnect(command);
+			} else if (action.startsWith(Stomp.Commands.DISCONNECT)) {
+				onStompDisconnect(command);
+			} else {
+				throw new ProtocolException("Unknown STOMP action: " + action);
+			}
+		} catch (Exception e) {
 
-            StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR, headers, baos.toByteArray());
-            sendToStomp(errorMessage);
+			// Let the stomp client know about any protocol errors.
+			ByteArrayOutputStream baos = new ByteArrayOutputStream();
+			PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos,
+					"UTF-8"));
+			e.printStackTrace(stream);
+			stream.close();
 
-            // TODO need to do anything else? Should we close the connection?
-        }
-    }
+			HashMap headers = new HashMap();
+			headers.put(Stomp.Headers.Error.MESSAGE, e.getMessage());
 
-    public void onException(Exception e) {
-        log.error("Caught: " + e, e);
-    }
+			final String receiptId = (String) command.getHeaders().get(
+					Stomp.Headers.RECEIPT_REQUESTED);
+			if (receiptId != null) {
+				headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId);
+			}
 
-    public void addMessageToAck(Message message) throws JMSException {
-        messages.put(message.getJMSMessageID(), message);
-    }
+			StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR,
+					headers, baos.toByteArray());
+			sendToStomp(errorMessage);
 
-    // Implemenation methods
-    //-------------------------------------------------------------------------
-    protected void onStompConnect(StompFrame command) throws Exception {
-        if (connection != null) {
-            throw new ProtocolException("Allready connected.");
-        }
+			// TODO need to do anything else? Should we close the connection?
+		}
+	}
 
-        final Map headers = command.getHeaders();
-        String login = (String) headers.get(Stomp.Headers.Connect.LOGIN);
-        String passcode = (String) headers.get(Stomp.Headers.Connect.PASSCODE);
-        String clientId = (String) headers.get(Stomp.Headers.Connect.CLIENT_ID);
+	public void onException(Exception e) {
+		log.error("Caught: " + e, e);
+	}
 
-        ConnectionFactory factory = getConnectionFactory();
-        IntrospectionSupport.setProperties(factory, headers, "factory.");
+	public boolean addMessageToAck(Message message, MessageConsumer consumer)
+			throws JMSException {
+		if (!closing) {
+			MSC ms = new MSC();
+			ms.message = message;
+			ms.consumer = consumer;
+			messages.put(message.getJMSMessageID(), ms);
+		}
+		return closing;
+	}
 
-        if (login != null) {
-            connection = factory.createConnection(login, passcode);
-        }
-        else {
-            connection = factory.createConnection();
-        }
-        if (clientId != null) {
-            connection.setClientID(clientId);
-        }
-        IntrospectionSupport.setProperties(connection, headers, "connection.");
+	// Implemenation methods
+	// -------------------------------------------------------------------------
+	protected void onStompConnect(StompFrame command) throws Exception {
+		if (connection != null) {
+			throw new ProtocolException("Allready connected.");
+		}
 
-        connection.start();
+		final Map headers = command.getHeaders();
+		String login = (String) headers.get(Stomp.Headers.Connect.LOGIN);
+		String passcode = (String) headers.get(Stomp.Headers.Connect.PASSCODE);
+		String clientId = (String) headers.get(Stomp.Headers.Connect.CLIENT_ID);
 
-        Map responseHeaders = new HashMap();
+		XAConnectionFactory factory = getConnectionFactory();
+		IntrospectionSupport.setProperties(factory, headers, "factory.");
 
-        responseHeaders.put(Stomp.Headers.Connected.SESSION, connection.getClientID());
-        String requestId = (String) headers.get(Stomp.Headers.Connect.REQUEST_ID);
-        if (requestId == null) {
-            // TODO legacy
-            requestId = (String) headers.get(Stomp.Headers.RECEIPT_REQUESTED);
-        }
-        if (requestId != null) {
-            // TODO legacy
-            responseHeaders.put(Stomp.Headers.Connected.RESPONSE_ID, requestId);
-            responseHeaders.put(Stomp.Headers.Response.RECEIPT_ID, requestId);
-        }
+		if (login != null) {
+			connection = factory.createXAConnection(login, passcode);
+		} else {
+			connection = factory.createXAConnection();
+		}
+		if (clientId != null) {
+			connection.setClientID(clientId);
+		}
+		IntrospectionSupport.setProperties(connection, headers, "connection.");
 
-        StompFrame sc = new StompFrame();
-        sc.setAction(Stomp.Responses.CONNECTED);
-        sc.setHeaders(responseHeaders);
-        sendToStomp(sc);
-    }
+		connection.start();
 
-    protected void onStompDisconnect(StompFrame command) throws Exception {
-        checkConnected();
-        close();
-    }
+		Map responseHeaders = new HashMap();
 
-    protected void onStompSend(StompFrame command) throws Exception {
-        checkConnected();
+		responseHeaders.put(Stomp.Headers.Connected.SESSION,
+				connection.getClientID());
+		String requestId = (String) headers
+				.get(Stomp.Headers.Connect.REQUEST_ID);
+		if (requestId == null) {
+			// TODO legacy
+			requestId = (String) headers.get(Stomp.Headers.RECEIPT_REQUESTED);
+		}
+		if (requestId != null) {
+			// TODO legacy
+			responseHeaders.put(Stomp.Headers.Connected.RESPONSE_ID, requestId);
+			responseHeaders.put(Stomp.Headers.Response.RECEIPT_ID, requestId);
+		}
 
-        Map headers = command.getHeaders();
-        String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
+		StompFrame sc = new StompFrame();
+		sc.setAction(Stomp.Responses.CONNECTED);
+		sc.setHeaders(responseHeaders);
+		sendToStomp(sc);
+	}
 
-        StompSession session;
-        if (stompTx != null) {
-            session = getExistingTransactedSession(stompTx);
-        }
-        else {
-            session = getDefaultSession();
-        }
+	protected void onStompDisconnect(StompFrame command) throws Exception {
+		checkConnected();
+		close();
+	}
 
-        session.sendToJms(command);
-        sendResponse(command);
-    }
+	protected void onStompSend(StompFrame command) throws Exception {
+		checkConnected();
 
-    protected void onStompBegin(StompFrame command) throws Exception {
-        checkConnected();
+		Map headers = command.getHeaders();
 
-        Map headers = command.getHeaders();
+		String xid = (String) headers.get("messagexid");
 
-        String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
+		if (xid != null) {
+			log.info("Transaction was propagated: " + xid);
+			JtsTransactionImple.resume(xid);
+			log.info("Resumed transaction");
 
-        if (stompTx == null) {
-            throw new ProtocolException("Must specify the transaction you are beginning");
-        }
+			javax.transaction.TransactionManager txMgr = (TransactionManager) new InitialContext()
+					.lookup("java:/TransactionManager");
+			StompSession session = getXASession();
 
-        StompSession session = getTransactedSession(stompTx);
-        if (session != null) {
-            throw new ProtocolException("The transaction was already started: " + stompTx);
-        }
-        session = createTransactedSession(stompTx);
-        setTransactedSession(stompTx, session);
+			XAResource xaRes = ((XASession)session.getSession()).getXAResource();
+			Transaction transaction = txMgr.getTransaction();
+			log.info("Got transaction: " + transaction);
+			transaction.enlistResource(xaRes);
+			log.info("Enlisted resource");
+			
+			session.sendToJms(command);
+			
+			transaction.delistResource(xaRes, XAResource.TMSUCCESS);
+			
+			log.info("Delisted resource");
+			JtsTransactionImple.suspend();
+			log.info("Suspended transaction");
+		} else {
+			log.info("WAS NULL XID");
 
-        sendResponse(command);
-    }
+			String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
 
-    protected void onStompCommit(StompFrame command) throws Exception {
-        checkConnected();
+			StompSession session;
+			if (stompTx != null) {
+				session = getExistingTransactedSession(stompTx);
+			} else {
+				session = getDefaultSession();
+			}
 
-        Map headers = command.getHeaders();
-        String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
-        if (stompTx == null) {
-            throw new ProtocolException("Must specify the transaction you are committing");
-        }
+			session.sendToJms(command);
+			log.info("Sent to JMS");
+		}
+		sendResponse(command);
+		log.info("Sent Response");
+	}
 
-        StompSession session = getExistingTransactedSession(stompTx);
-        session.getSession().commit();
-        considerClosingTransactedSession(session, stompTx);
-        sendResponse(command);
-    }
+	protected void onStompBegin(StompFrame command) throws Exception {
+		checkConnected();
 
-    protected void onStompAbort(StompFrame command) throws Exception {
-        checkConnected();
-        Map headers = command.getHeaders();
+		Map headers = command.getHeaders();
 
-        String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
-        if (stompTx == null) {
-            throw new ProtocolException("Must specify the transaction you are committing");
-        }
+		String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
 
-        StompSession session = getExistingTransactedSession(stompTx);
-        session.getSession().rollback();
-        considerClosingTransactedSession(session, stompTx);
-        sendResponse(command);
-    }
+		if (stompTx == null) {
+			throw new ProtocolException(
+					"Must specify the transaction you are beginning");
+		}
 
-    protected void onStompSubscribe(StompFrame command) throws Exception {
-        checkConnected();
+		StompSession session = getTransactedSession(stompTx);
+		if (session != null) {
+			throw new ProtocolException("The transaction was already started: "
+					+ stompTx);
+		}
+		session = createTransactedSession(stompTx);
+		setTransactedSession(stompTx, session);
 
-        Map headers = command.getHeaders();
-        String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
+		sendResponse(command);
+	}
 
-        StompSession session;
-        if (stompTx != null) {
-            session = getExistingTransactedSession(stompTx);
-        }
-        else {
-            String ackMode = (String) headers.get(Stomp.Headers.Subscribe.ACK_MODE);
-            if (ackMode != null && Stomp.Headers.Subscribe.AckModeValues.CLIENT.equals(ackMode)) {
-                session = getClientAckSession();
-            }
-            else {
-                session = getDefaultSession();
-            }
-        }
+	protected void onStompCommit(StompFrame command) throws Exception {
+		checkConnected();
 
-        String subscriptionId = (String) headers.get(Stomp.Headers.Subscribe.ID);
-        if (subscriptionId == null) {
-            subscriptionId = createSubscriptionId(headers);
-        }
+		Map headers = command.getHeaders();
+		String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
+		if (stompTx == null) {
+			throw new ProtocolException(
+					"Must specify the transaction you are committing");
+		}
 
-        StompSubscription subscription = (StompSubscription) subscriptions.get(subscriptionId);
-        if (subscription != null) {
-            throw new ProtocolException("There already is a subscription for: " + subscriptionId + ". Either use unique subscription IDs or do not create multiple subscriptions for the same destination");
-        }
-        subscription = new StompSubscription(session, subscriptionId, command);
-        subscriptions.put(subscriptionId, subscription);
-        sendResponse(command);
-    }
+		StompSession session = getExistingTransactedSession(stompTx);
+		session.getSession().commit();
+		considerClosingTransactedSession(session, stompTx);
+		sendResponse(command);
+	}
 
-    protected void onStompUnsubscribe(StompFrame command) throws Exception {
-        checkConnected();
-        Map headers = command.getHeaders();
+	protected void onStompAbort(StompFrame command) throws Exception {
+		checkConnected();
+		Map headers = command.getHeaders();
 
-        String destinationName = (String) headers.get(Stomp.Headers.Unsubscribe.DESTINATION);
-        String subscriptionId = (String) headers.get(Stomp.Headers.Unsubscribe.ID);
+		String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
+		if (stompTx == null) {
+			throw new ProtocolException(
+					"Must specify the transaction you are committing");
+		}
 
-        if (subscriptionId == null) {
-            if (destinationName == null) {
-                throw new ProtocolException("Must specify the subscriptionId or the destination you are unsubscribing from");
-            }
-            subscriptionId = createSubscriptionId(headers);
-        }
+		StompSession session = getExistingTransactedSession(stompTx);
+		session.getSession().rollback();
+		considerClosingTransactedSession(session, stompTx);
+		sendResponse(command);
+	}
 
-        StompSubscription subscription = (StompSubscription) subscriptions.remove(subscriptionId);
-        if (subscription == null) {
-            throw new ProtocolException("Cannot unsubscribe as mo subscription exists for id: " + subscriptionId);
-        }
-        subscription.close();
-        sendResponse(command);
-    }
+	protected void onStompSubscribe(StompFrame command) throws Exception {
+		checkConnected();
 
-    protected void onStompAck(StompFrame command) throws Exception {
-        checkConnected();
+		Map headers = command.getHeaders();
+		String stompTx = (String) headers.get(Stomp.Headers.TRANSACTION);
 
-        // TODO: acking with just a message id is very bogus
-        // since the same message id could have been sent to 2 different subscriptions
-        // on the same stomp connection. For example, when 2 subs are created on the same topic.
+		StompSession session;
+		if (stompTx != null) {
+			session = getExistingTransactedSession(stompTx);
+		} else {
+			String ackMode = (String) headers
+					.get(Stomp.Headers.Subscribe.ACK_MODE);
+			if (ackMode != null
+					&& Stomp.Headers.Subscribe.AckModeValues.CLIENT
+							.equals(ackMode)) {
+				session = getClientAckSession();
+			} else {
+				session = getDefaultSession();
+			}
+		}
 
-        Map headers = command.getHeaders();
-        String messageId = (String) headers.get(Stomp.Headers.Ack.MESSAGE_ID);
-        if (messageId == null) {
-            throw new ProtocolException("ACK received without a message-id to acknowledge!");
-        }
+		String subscriptionId = (String) headers
+				.get(Stomp.Headers.Subscribe.ID);
+		if (subscriptionId == null) {
+			subscriptionId = createSubscriptionId(headers);
+		}
 
-        Message message = (Message) messages.remove(messageId);
-        if (message == null) {
-            throw new ProtocolException("No such message for message-id: " + messageId);
-        }
-        message.acknowledge();
-        sendResponse(command);
-    }
+		StompSubscription subscription = (StompSubscription) subscriptions
+				.get(subscriptionId);
+		if (subscription != null) {
+			throw new ProtocolException(
+					"There already is a subscription for: "
+							+ subscriptionId
+							+ ". Either use unique subscription IDs or do not create multiple subscriptions for the same destination");
+		}
+		subscription = new StompSubscription(session, subscriptionId, command);
+		subscriptions.put(subscriptionId, subscription);
+		sendResponse(command);
+	}
 
-    protected void checkConnected() throws ProtocolException {
-        if (connection == null) {
-            throw new ProtocolException("Not connected.");
-        }
-    }
+	protected void onStompUnsubscribe(StompFrame command) throws Exception {
+		checkConnected();
+		Map headers = command.getHeaders();
 
-    /**
-     * Auto-create a subscription ID using the destination
-     */
-    protected String createSubscriptionId(Map headers) {
-        return "/subscription-to/" + headers.get(Stomp.Headers.Subscribe.DESTINATION);
-    }
+		String destinationName = (String) headers
+				.get(Stomp.Headers.Unsubscribe.DESTINATION);
+		String subscriptionId = (String) headers
+				.get(Stomp.Headers.Unsubscribe.ID);
 
-    protected StompSession getDefaultSession() throws JMSException {
-        if (defaultSession == null) {
-            defaultSession = createSession(Session.AUTO_ACKNOWLEDGE);
-        }
-        return defaultSession;
-    }
+		if (subscriptionId == null) {
+			if (destinationName == null) {
+				throw new ProtocolException(
+						"Must specify the subscriptionId or the destination you are unsubscribing from");
+			}
+			subscriptionId = createSubscriptionId(headers);
+		}
 
-    protected StompSession getClientAckSession() throws JMSException {
-        if (clientAckSession == null) {
-            clientAckSession = createSession(Session.CLIENT_ACKNOWLEDGE);
-        }
-        return clientAckSession;
-    }
+		StompSubscription subscription = (StompSubscription) subscriptions
+				.remove(subscriptionId);
+		if (subscription == null) {
+			throw new ProtocolException(
+					"Cannot unsubscribe as mo subscription exists for id: "
+							+ subscriptionId);
+		}
+		subscription.close();
+		sendResponse(command);
+	}
 
-    /**
-     * Returns the transacted session for the given ID or throws an exception if there is no such session
-     */
-    protected StompSession getExistingTransactedSession(String stompTx) throws ProtocolException, JMSException {
-        StompSession session = getTransactedSession(stompTx);
-        if (session == null) {
-            throw new ProtocolException("Invalid transaction id: " + stompTx);
-        }
-        return session;
-    }
+	protected void onStompAck(StompFrame command) throws Exception {
+		checkConnected();
 
-    protected StompSession getTransactedSession(String stompTx) throws ProtocolException, JMSException {
-        return (StompSession) transactedSessions.get(stompTx);
-    }
+		// TODO: acking with just a message id is very bogus
+		// since the same message id could have been sent to 2 different
+		// subscriptions
+		// on the same stomp connection. For example, when 2 subs are created on
+		// the same topic.
 
-    protected void setTransactedSession(String stompTx, StompSession session) {
-        transactedSessions.put(stompTx, session);
-    }
+		Map headers = command.getHeaders();
+		String messageId = (String) headers.get(Stomp.Headers.Ack.MESSAGE_ID);
+		if (messageId == null) {
+			throw new ProtocolException(
+					"ACK received without a message-id to acknowledge!");
+		}
 
-    protected StompSession createSession(int ackMode) throws JMSException {
-        Session session = connection.createSession(false, ackMode);
-        if (log.isDebugEnabled()) {
-            log.debug("Created session with ack mode: " + session.getAcknowledgeMode());
-        }
-        return new StompSession(this, session);
-    }
+		MSC ms = (MSC) messages.remove(messageId);
+		if (ms == null) {
+			throw new ProtocolException("No such message for message-id: "
+					+ messageId);
+		}
 
-    protected StompSession createTransactedSession(String stompTx) throws JMSException {
-        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-        return new StompSession(this, session);
-    }
+		// PATCHED BY TOM FOR SINGLE MESSAGE DELIVERY
+		synchronized (ms.consumer) {
+			ms.message.acknowledge();
+			ms.consumer.notify();
+		}
+		sendResponse(command);
+	}
 
-    protected void sendResponse(StompFrame command) throws Exception {
-        final String receiptId = (String) command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED);
-        // A response may not be needed.
-        if (receiptId != null) {
-            StompFrame sc = new StompFrame();
-            sc.setAction(Stomp.Responses.RECEIPT);
-            sc.setHeaders(new HashMap(1));
-            sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId);
-            sendToStomp(sc);
-        }
-    }
+	protected void checkConnected() throws ProtocolException {
+		if (connection == null) {
+			throw new ProtocolException("Not connected.");
+		}
+	}
 
-    protected void sendToStomp(StompFrame frame) throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug("<<<< " + frame.getAction() + " headers: " + frame.getHeaders());
-        }
-        outputHandler.onStompFrame(frame);
-    }
+	/**
+	 * Auto-create a subscription ID using the destination
+	 */
+	protected String createSubscriptionId(Map headers) {
+		return "/subscription-to/"
+				+ headers.get(Stomp.Headers.Subscribe.DESTINATION);
+	}
 
-    /**
-     * A provider may wish to eagerly close transacted sessions when they are no longer used.
-     * Though a better option would be to just time them out after they have no longer been used.
-     */
-    protected void considerClosingTransactedSession(StompSession session, String stompTx) {
-    }
+	protected StompSession getDefaultSession() throws JMSException {
+		if (defaultSession == null) {
+			defaultSession = createSession(Session.AUTO_ACKNOWLEDGE);
+		}
+		return defaultSession;
+	}
+
+	protected StompSession getClientAckSession() throws JMSException {
+		if (clientAckSession == null) {
+			clientAckSession = createSession(Session.CLIENT_ACKNOWLEDGE);
+		}
+		return clientAckSession;
+	}
+
+	protected StompSession getXASession() throws JMSException {
+		if (xaSession == null) {
+			Session session = connection.createXASession();
+			if (log.isDebugEnabled()) {
+				log.debug("Created XA session");
+			}
+			xaSession = new StompSession(this, session);
+			log.info("Created XA Session");
+		} else {
+			log.info("Returned existing XA session");
+		}
+		return xaSession;
+	}
+
+	/**
+	 * Returns the transacted session for the given ID or throws an exception if
+	 * there is no such session
+	 */
+	protected StompSession getExistingTransactedSession(String stompTx)
+			throws ProtocolException, JMSException {
+		StompSession session = getTransactedSession(stompTx);
+		if (session == null) {
+			throw new ProtocolException("Invalid transaction id: " + stompTx);
+		}
+		return session;
+	}
+
+	protected StompSession getTransactedSession(String stompTx)
+			throws ProtocolException, JMSException {
+		return (StompSession) transactedSessions.get(stompTx);
+	}
+
+	protected void setTransactedSession(String stompTx, StompSession session) {
+		transactedSessions.put(stompTx, session);
+	}
+
+	protected StompSession createSession(int ackMode) throws JMSException {
+		Session session = connection.createSession(false, ackMode);
+		if (log.isDebugEnabled()) {
+			log.debug("Created session with ack mode: "
+					+ session.getAcknowledgeMode());
+		}
+		return new StompSession(this, session);
+	}
+
+	protected StompSession createTransactedSession(String stompTx)
+			throws JMSException {
+		Session session = connection.createSession(true,
+				Session.SESSION_TRANSACTED);
+		return new StompSession(this, session);
+	}
+
+	protected void sendResponse(StompFrame command) throws Exception {
+		final String receiptId = (String) command.getHeaders().get(
+				Stomp.Headers.RECEIPT_REQUESTED);
+		// A response may not be needed.
+		if (receiptId != null) {
+			StompFrame sc = new StompFrame();
+			sc.setAction(Stomp.Responses.RECEIPT);
+			sc.setHeaders(new HashMap(1));
+			sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId);
+			sendToStomp(sc);
+		}
+	}
+
+	protected void sendToStomp(StompFrame frame) throws Exception {
+		if (log.isDebugEnabled()) {
+			log.debug("<<<< " + frame.getAction() + " headers: "
+					+ frame.getHeaders());
+		}
+		outputHandler.onStompFrame(frame);
+	}
+
+	/**
+	 * A provider may wish to eagerly close transacted sessions when they are no
+	 * longer used. Though a better option would be to just time them out after
+	 * they have no longer been used.
+	 */
+	protected void considerClosingTransactedSession(StompSession session,
+			String stompTx) {
+	}
+
+	private class MSC {
+		public Message message;
+		public Session session;
+		public MessageConsumer consumer;
+	}
 }
Index: src/main/java/org/codehaus/stomp/jms/StompConnect.java
===================================================================
--- src/main/java/org/codehaus/stomp/jms/StompConnect.java	(revision 90)
+++ src/main/java/org/codehaus/stomp/jms/StompConnect.java	(working copy)
@@ -17,22 +17,24 @@
  */
 package org.codehaus.stomp.jms;
 
-import org.codehaus.stomp.StompHandler;
-import org.codehaus.stomp.StompHandlerFactory;
-import org.codehaus.stomp.tcp.TcpTransportServer;
-import org.codehaus.stomp.util.ServiceSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Hashtable;
 
 import javax.jms.ConnectionFactory;
+import javax.jms.XAConnectionFactory;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.net.ServerSocketFactory;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Hashtable;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.stomp.StompHandler;
+import org.codehaus.stomp.StompHandlerFactory;
+import org.codehaus.stomp.tcp.TcpTransportServer;
+import org.codehaus.stomp.util.ServiceSupport;
+
 /**
  * This class represents a service which accepts STOMP socket connections and binds them to JMS operations
  *
@@ -41,7 +43,7 @@
 public class StompConnect extends ServiceSupport implements StompHandlerFactory {
     private static final transient Log log = LogFactory.getLog(StompConnect.class);
 
-    private ConnectionFactory connectionFactory;
+    private XAConnectionFactory connectionFactory;
     private String uri = "tcp://localhost:61613";
     private URI location;
     private ServerSocketFactory serverSocketFactory;
@@ -53,12 +55,12 @@
     public StompConnect() {
     }
 
-    public StompConnect(ConnectionFactory connectionFactory) {
+    public StompConnect(XAConnectionFactory connectionFactory) {
         this.connectionFactory = connectionFactory;
     }
 
     public StompHandler createStompHandler(StompHandler outputHandler) throws NamingException {
-        ConnectionFactory factory = getConnectionFactory();
+        XAConnectionFactory factory = getConnectionFactory();
         if (factory == null) {
             throw new IllegalArgumentException("No ConnectionFactory is configured!");
         }
@@ -74,7 +76,7 @@
 
     // Properties
     //-------------------------------------------------------------------------
-    public ConnectionFactory getConnectionFactory() throws NamingException {
+    public XAConnectionFactory getConnectionFactory() throws NamingException {
         if (connectionFactory == null) {
             connectionFactory = createConnectionFactory();
         }
@@ -84,7 +86,7 @@
     /**
      * Sets the JMS connection factory to use to communicate with
      */
-    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+    public void setConnectionFactory(XAConnectionFactory connectionFactory) {
         this.connectionFactory = connectionFactory;
     }
 
@@ -181,7 +183,7 @@
     // Implementation methods
     //-------------------------------------------------------------------------
     protected void doStart() throws Exception {
-        ConnectionFactory factory = getConnectionFactory();
+        XAConnectionFactory factory = getConnectionFactory();
         if (factory == null) {
             throw new IllegalArgumentException("No ConnectionFactory has been configured!");
         }
@@ -201,7 +203,7 @@
      * Factory method to lazily create a {@link ConnectionFactory} if one is not explicitly configured.
      * By default lets try looking in JNDI
      */
-    protected ConnectionFactory createConnectionFactory() throws NamingException {
+    protected XAConnectionFactory createConnectionFactory() throws NamingException {
         String name = getJndiName();
         log.info("Looking up name: " + name + " in JNDI InitialContext for JMS ConnectionFactory");
 
@@ -209,8 +211,8 @@
         if (value == null) {
             throw new IllegalArgumentException("No ConnectionFactory object is available in JNDI at name: " + name);
         }
-        if (value instanceof ConnectionFactory) {
-            return (ConnectionFactory) value;
+        if (value instanceof XAConnectionFactory) {
+            return (XAConnectionFactory) value;
         }
         else {
             throw new IllegalArgumentException("The object in JNDI at name: " + name
Index: pom.xml
===================================================================
--- pom.xml	(revision 90)
+++ pom.xml	(working copy)
@@ -3,8 +3,14 @@
   <groupId>org.codehaus.stomp</groupId>
   <artifactId>stompconnect</artifactId>
   <packaging>jar</packaging>
-  <version>1.0</version>
-
+  <version>1.0.3-BT-SNAPSHOT</version>
+  
+  <developers>
+	<developer>
+		<id>one</id>
+      		<name>one</name>
+	</developer>
+  </developers>	
   <name>StompConnect</name>
   <description>
     StompConnect allows any Message Orientated Middleware (MOM)
@@ -33,6 +39,50 @@
   </scm>
 
   <dependencies>
+  		<!-- Transactions START -->
+		<dependency>
+			<groupId>org.jboss.javaee</groupId>
+			<artifactId>jboss-javaee</artifactId>
+			<scope>provided</scope>
+		<version>5.0.1.GA</version>
+		</dependency>
+		<dependency>
+			<groupId>jboss.jbossts</groupId>
+			<artifactId>jbossjts</artifactId>
+			<scope>provided</scope>
+		<version>4.6.1.GA</version>
+		</dependency>
+		<dependency>
+			<groupId>jboss.jbossts</groupId>
+			<artifactId>jbossjts-jacorb</artifactId>
+			<scope>provided</scope>
+		<version>4.6.1.GA</version>
+		</dependency>
+		<!-- Transactions END -->
+  		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.15</version>
+			<exclusions>
+				<exclusion>
+					<groupId>com.sun.jmx</groupId>
+					<artifactId>jmxri</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jdmk</groupId>
+					<artifactId>jmxtools</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.jms</groupId>
+					<artifactId>jms</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.mail</groupId>
+					<artifactId>mail</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+  
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
@@ -122,6 +172,11 @@
     </extensions>
 
     <plugins>
+ <plugin>
+ <!-- Entry needed to create, install and deploy sources jars -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
       <plugin>
         <artifactId>maven-release-plugin</artifactId>
         <configuration>
