Index: src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
===================================================================
--- src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java	(revision 110403)
+++ src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java	(working copy)
@@ -378,6 +378,7 @@
 
       ResourceAdapter resourceAdapter = null;
       ConnectionDefinitionMetaData cdmd = cmd.getConnectionDefinition(dmd.getConnectionDefinition());
+      rarName = dmd.getRarName();
       
       try
       {
@@ -550,17 +551,33 @@
                ManagedConnection mc = open(subject);
                XAResource xaResource = null;
 
+               Object connection = null;
                try
                {
                   xaResource = mc.getXAResource();
+                  connection = openConnection(mc, subject);
                }
                catch (ResourceException reconnect)
                {
+                  closeConnection(connection);
+                  connection = null;
                   close(mc);
                   mc = open(subject);
                   xaResource = mc.getXAResource();
                }
+               finally
+               {
+                  boolean forceDestroy = closeConnection(connection);
+                  connection = null;
 
+                  if (forceDestroy)
+                  {
+                     close(mc);
+                     mc = open(subject);
+                     xaResource = mc.getXAResource();
+                  }
+               }
+
                try
                {
                   ObjectName on = new ObjectName(connectionManager);
@@ -607,7 +624,8 @@
                }
                catch (Throwable t)
                {
-                  // Ignore
+                  if (log.isDebugEnabled())
+                     log.debug("Unable to verify wrap-xa settings for " + dmd.getJndiName(), t);
                }
 
                if (log.isDebugEnabled())
@@ -623,8 +641,7 @@
          }
          catch (ResourceException re)
          {
-            if (log.isDebugEnabled())
-               log.debug("Error during recovery", re);
+            log.warn("Error during recovery", re);
          }
       }
       else
@@ -715,7 +732,7 @@
                }
                catch (Throwable t)
                {
-                  log.debug("Exception during getSubject()" + t.getMessage(), t);
+                  log.warn("Exception during getSubject()" + t.getMessage(), t);
                }
 
                return null;
@@ -754,8 +771,7 @@
          }
          catch (ResourceException ire)
          {
-            if (log.isDebugEnabled())
-               log.debug("Error during recovery cleanup", ire);
+            log.warn("Error during recovery cleanup", ire);
          }
       }
 
@@ -767,13 +783,70 @@
          }
          catch (ResourceException ire)
          {
-            if (log.isDebugEnabled())
-               log.debug("Error during recovery destroy", ire);
+            log.warn("Error during recovery destroy", ire);
          }
       }
 
       mc = null;
    }
+
+   /**
+    * Open a connection
+    * @param mc The managed connection
+    * @param s The subject
+    * @return The connection handle
+    * @exception ResourceException Thrown in case of an error
+    */
+   private Object openConnection(ManagedConnection mc, Subject s) throws ResourceException
+   {
+      return mc.getConnection(s, null);
+   }
+
+   /**
+    * Close a connection
+    * @param c The connection
+    * @return Should the managed connection be forced closed
+    */
+   private boolean closeConnection(Object c)
+   {
+      if (c != null)
+      {
+         if (c instanceof javax.resource.cci.Connection)
+         {
+            try
+            {
+               javax.resource.cci.Connection cci = (javax.resource.cci.Connection)c;
+               cci.close();
+            }
+            catch (ResourceException ire)
+            {
+               log.warn("Error during recovery connection close", ire);
+               return true;
+            }
+         }
+         else
+         {
+            try
+            {
+               Method method = c.getClass().getMethod("close", new Class[0]);
+               method.setAccessible(true);
+               method.invoke(c, new Object[0]);
+            }
+            catch (NoSuchMethodException nsme)
+            {
+               log.warn("No close() method defined on connection interface. Destroying managed connection to clean-up", nsme);
+               return true;
+            }
+            catch (Throwable t)
+            {
+               log.warn("Error during recovery connection close", t);
+               return true;
+            }
+         }
+      }
+
+      return false;
+   }
    
    public void setManagedConnectionFactoryAttribute(String name, Class clazz, Object value)
    {
