Index: common/.classpath
===================================================================
--- common/.classpath	(revision 111501)
+++ common/.classpath	(working copy)
@@ -10,10 +10,6 @@
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-logging.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/papaki-core.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/sjc/fungal.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-api.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-impl-base.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-junit.jar" sourcepath="/dati/project/RH/arquillian/impl-base/src/main/java"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-spi.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-api.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-impl-base.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/test/h2.jar"/>
Index: core/.classpath
===================================================================
--- core/.classpath	(revision 111501)
+++ core/.classpath	(working copy)
@@ -18,9 +18,6 @@
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/test/h2.jar"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-embedded"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/picketbox.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-impl-base.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-junit.jar" sourcepath="/dati/project/RH/arquillian/impl-base/src/main/java"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-api.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/commons-logging.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/hibernate-validator.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/javassist.jar"/>
@@ -42,5 +39,6 @@
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-transaction-api_1.1_spec.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jbossjta-integration.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jbossjta.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-descriptors-api.jar"/>
 	<classpathentry kind="output" path="eclipse-target/classes"/>
 </classpath>
Index: core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockManagedConnection.java
===================================================================
--- core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockManagedConnection.java	(revision 111501)
+++ core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockManagedConnection.java	(working copy)
@@ -91,9 +91,11 @@
     * {@inheritDoc}
     */
 
+   MockHandle handle = new MockHandle();
+   
    public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
    {
-      return new MockHandle();
+      return handle;
    }
 
    /**
Index: core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
===================================================================
--- core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java	(revision 111501)
+++ core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java	(working copy)
@@ -22,7 +22,6 @@
 package org.jboss.jca.core.connectionmanager.tx;
 
 import org.jboss.jca.common.api.metadata.common.FlushStrategy;
-import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
 import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
 import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
 import org.jboss.jca.core.connectionmanager.TxConnectionManager;
@@ -54,6 +53,8 @@
 import static org.hamcrest.core.IsInstanceOf.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
@@ -98,8 +99,118 @@
          throw e;
       }
    }
+   
+   
+   /**
+    * testSuccessiveAllocateConnectionReqeustsInTheSameTransactionReturnTheSameConnection
+    * @throws Throwable for exception
+    */
+   @Test
+   public void testSuccessiveAllocateConnectionReqeustsInTheSameTransactionReturnTheSameConnection() throws Throwable
+   {
+      TransactionManager transactionManager = txConnectionManager.getTransactionIntegration().getTransactionManager();
 
+      assertNotNull(transactionManager);
+      try
+      {
+         transactionManager.begin();
+
+         Object handle1 = txConnectionManager.allocateConnection(mcf, new MockConnectionRequestInfo());
+         Object handle2 = txConnectionManager.allocateConnection(mcf, new MockConnectionRequestInfo());
+
+         assertSame(handle1, handle2);
+
+         transactionManager.commit();
+      }
+      catch (Throwable e)
+      {
+         transactionManager.rollback();
+         throw e;
+      }
+   }
+   
+
    /**
+    * testSuccessiveAllocateConnectionReqeustsInDifferentTransactionsReturnDifferentConnections
+    * @throws Throwable for exception
+    */
+   @Test
+   public void testSuccessiveAllocateConnectionReqeustsInDifferentTransactionsReturnDifferentConnections() 
+      throws Throwable
+   {
+      TransactionManager transactionManager = txConnectionManager.getTransactionIntegration().getTransactionManager();
+      
+      assertNotNull(transactionManager);
+      Object handle1;
+      Object handle2;
+      try
+      {
+         transactionManager.begin();
+         
+         handle1 = txConnectionManager.allocateConnection(mcf, new MockConnectionRequestInfo());
+         
+         transactionManager.commit();
+      }
+      catch (Throwable e)
+      {
+         transactionManager.rollback();
+         throw e;
+      }
+      
+      try
+      {
+         transactionManager.begin();
+          
+         handle2 = txConnectionManager.allocateConnection(mcf, new MockConnectionRequestInfo());
+         
+         transactionManager.commit();
+      }
+      catch (Throwable e)
+      {
+         transactionManager.rollback();
+         throw e;
+      }
+       
+      assertNotSame(handle1, handle2);
+   }
+
+   /**
+    * testAllocateConnectionReqeustsToDiffrntConnectionManagrsInTheSameTransactionReturnDifferentConnections
+    * @throws Throwable for exception
+    */
+   @Test
+   public void testAllocateConnectionReqeustsToDiffrntConnectionManagrsInTheSameTransactionReturnDifferentConnections()
+      throws Throwable
+   {
+      TransactionManager transactionManager = txConnectionManager.getTransactionIntegration().getTransactionManager();
+
+      TxConnectionManager txConnectionManager1 = txConnectionManager;
+      ManagedConnectionFactory mcf1 = mcf;
+      
+      ManagedConnectionFactory mcf2 = new MockManagedConnectionFactory();
+      TxConnectionManager txConnectionManager2 = buildTxConnectionManager(mcf2);
+      
+      assertNotNull(transactionManager);
+      try
+      {
+         transactionManager.begin();
+         
+         Object handle1 = txConnectionManager1.allocateConnection(mcf1, new MockConnectionRequestInfo());
+         Object handle2 = txConnectionManager2.allocateConnection(mcf2, new MockConnectionRequestInfo());
+
+         assertNotSame(handle1, handle2);
+         
+         transactionManager.commit();
+      }
+      catch (Throwable e)
+      {
+         transactionManager.rollback();
+         throw e;
+      }
+   
+   } 
+
+   /**
     * testGetTimeLeftBeforeTrsTimeout.
     * @throws Throwable for exception
     */
@@ -304,22 +415,25 @@
       embedded.deploy(naming);
       embedded.deploy(transaction);
 
+
+      mcf = new MockManagedConnectionFactory();
+      txConnectionManager = buildTxConnectionManager(mcf);
+   }
+
+   private static TxConnectionManager buildTxConnectionManager(ManagedConnectionFactory mcf) throws Throwable
+   {
       TransactionIntegration ti = embedded.lookup("TransactionIntegration", TransactionIntegration.class);
       assertNotNull(ti);
-
-      mcf = new MockManagedConnectionFactory();
+      
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
-
+    
       Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
-
+      
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
-      ConnectionManager connectionManager = 
-         cmf.createTransactional(TransactionSupportLevel.LocalTransaction, pool,
-                                 null, null, false, null, FlushStrategy.FAILING_CONNECTION_ONLY,
-                                 null, null, ti, null, null, null, null, null);
-
-      txConnectionManager = (TxConnectionManager) connectionManager;
+      return (TxConnectionManager) cmf.createTransactional(TransactionSupportLevel.XATransaction, pool,
+                                   null, null, false, null, FlushStrategy.FAILING_CONNECTION_ONLY,
+                                   null, null, ti, null, null, null, null, null);
    }
 
    /**
Index: core/src/main/java/org/jboss/jca/core/connectionmanager/transaction/TransactionKey.java
===================================================================
--- core/src/main/java/org/jboss/jca/core/connectionmanager/transaction/TransactionKey.java	(revision 111501)
+++ core/src/main/java/org/jboss/jca/core/connectionmanager/transaction/TransactionKey.java	(working copy)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jca.core.connectionmanager.transaction;
-
-import javax.transaction.Transaction;
-
-/**
- * Defines a transaction key 
- * 
- * @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
- */
-public class TransactionKey
-{
-   private Transaction tx;
-
-   /**
-    * Constructor
-    * @param tx The transaction
-    */
-   public TransactionKey(Transaction tx)
-   {
-      this.tx = tx;
-   }
-
-   /**
-    * Equals
-    * @param other The other object
-    * @return True if equal; otherwise false
-    */
-   public boolean equals(Object other)
-   {
-      if (this == other)
-         return true;
-
-      if (other == null || !(other instanceof TransactionKey))
-         return false;
-
-      TransactionKey tk = (TransactionKey)other;
-      return tx.equals(tk.tx);
-   }
-
-   /**
-    * Hash code
-    * @return The value
-    */
-   public int hashCode()
-   {
-      return tx.hashCode();
-   }
-}
Index: core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
===================================================================
--- core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java	(revision 111501)
+++ core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java	(working copy)
@@ -30,7 +30,6 @@
 import org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPool;
 import org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPoolFactory;
 import org.jboss.jca.core.connectionmanager.transaction.LockKey;
-import org.jboss.jca.core.connectionmanager.transaction.TransactionKey;
 import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 
 import java.util.HashSet;
@@ -346,9 +345,9 @@
 
       // Are we doing track by transaction ?
       TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
-      Object trackByTx = tsr != null ? tsr.getTransactionKey() : null;
+      Object transactionKey = tsr != null ? tsr.getTransactionKey() : null;
 
-      if (trackByTransaction == null || trackByTx == null)
+      if (trackByTransaction == null || transactionKey == null)
       {
          return getSimpleConnection(subject, cri, mcp);
       }
@@ -356,7 +355,7 @@
       // Transaction old connections
       if (cl == null)
       {
-         cl = getTransactionOldConnection(trackByTransaction);
+         cl = getTransactionOldConnection(trackByTransaction, mcp);
       }
 
       // Creates a new connection with given transaction
@@ -421,10 +420,11 @@
     * This method is package protected beacause it is intended only for test case use.
     * Please don't use it in your production code.
     * @param trackByTransaction transaction instance
+    * @param mcp the managed connection pool associated with the desired connection listener
     * @return connection listener instance
     * @throws ResourceException Thrown if an error occurs
     */
-   ConnectionListener getTransactionOldConnection(Transaction trackByTransaction)
+   ConnectionListener getTransactionOldConnection(Transaction trackByTransaction, ManagedConnectionPool mcp)
       throws ResourceException
    {
       TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
@@ -441,10 +441,11 @@
       try
       {
          // Already got one
-         ConnectionListener cl = (ConnectionListener)tsr.getResource(new TransactionKey(trackByTransaction));
+         ConnectionListener cl = (ConnectionListener)tsr.getResource(mcp);
          if (cl != null)
          {
             log.tracef("Previous connection tracked by transaction=%s tx=%s", cl, trackByTransaction);
+            assert cl.getContext().equals(mcp);
             return cl;
          }
 
@@ -494,7 +495,7 @@
       {
          // Check we weren't racing with another transaction
          ConnectionListener other =
-            (ConnectionListener)tsr.getResource(new TransactionKey(trackByTransaction));
+            (ConnectionListener)tsr.getResource(mcp);
 
          if (other != null)
          {
@@ -508,7 +509,7 @@
 
          // This is the connection for this transaction
          cl.setTrackByTx(true);
-         tsr.putResource(new TransactionKey(trackByTransaction), cl);
+         tsr.putResource(mcp, cl);
 
          log.tracef("Using connection from pool tracked by transaction=%s tx=%s", cl, trackByTransaction);
 
Index: core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
===================================================================
--- core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java	(revision 111501)
+++ core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java	(working copy)
@@ -29,7 +29,6 @@
 import org.jboss.jca.core.connectionmanager.listener.TxConnectionListener;
 import org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPool;
 import org.jboss.jca.core.connectionmanager.transaction.LockKey;
-import org.jboss.jca.core.connectionmanager.transaction.TransactionKey;
 import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration;
 import org.jboss.jca.core.spi.transaction.TxUtils;
@@ -399,7 +398,7 @@
 
                try
                {
-                  transactionSynchronizationRegistry.putResource(new TransactionKey(tx), cl);
+                  transactionSynchronizationRegistry.putResource(mcp, cl);
                }
                finally
                {
Index: embedded/.classpath
===================================================================
--- embedded/.classpath	(revision 111501)
+++ embedded/.classpath	(working copy)
@@ -8,15 +8,10 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-api"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-common"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-api.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-junit.jar" sourcepath="/dati/project/RH/arquillian/impl-base/src/main/java"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-protocol-local.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-spi.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-testenricher-resource.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-api.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-logging.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/sjc/fungal.jar"/>
-	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-impl-base.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jnpserver.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-stdio.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/hibernate-validator.jar"/>
@@ -25,5 +20,11 @@
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-transaction-api_1.1_spec.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jbossjta-integration.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jbossjta.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-descriptors-api.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-container-spi.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-core-api.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-core-spi.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-container-test-api.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-junit-core.jar"/>
 	<classpathentry kind="output" path="eclipse-target/classes"/>
 </classpath>
