JBossXAResource res1 = (JBossXAResource)sess1.getXAResource();
MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
   public void testMultipleSessionsOneTxCommitAcknowledge() throws Exception   {      if (ServerManagement.isRemote()) return;            XAConnection conn = null;      Connection conn2 = null;            try      {         //First send 2 messages         conn2 = cf.createConnection();         Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageProducer prod  = sessProducer.createProducer(queue);         Message m = sessProducer.createTextMessage("jellyfish1");         prod.send(m);         m = sessProducer.createTextMessage("jellyfish2");         prod.send(m);                           conn = cf.createXAConnection();         conn.start();                     tm.begin();                  //Create 2 sessions and enlist them         XASession sess1 = conn.createXASession();         JBossXAResource res1 = (JBossXAResource)sess1.getXAResource();         XASession sess2 = conn.createXASession();         JBossXAResource res2 = (JBossXAResource)sess2.getXAResource();         res1.setPreventJoining(true);         res2.setPreventJoining(true);                  Transaction tx = tm.getTransaction();         tx.enlistResource(res1);         tx.enlistResource(res2);                  //Receive the messages, one on each consumer         MessageConsumer cons1 = sess1.createConsumer(queue);         TextMessage r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish1", r1.getText());                           cons1.close();                  MessageConsumer cons2 = sess2.createConsumer(queue);         TextMessage r2 = (TextMessage)cons2.receive(1000);                  assertNotNull(r2);         assertEquals("jellyfish2", r2.getText());                  //commit                 tx.commit();                  Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageConsumer cons = sess.createConsumer(queue);         conn2.start();                  TextMessage r3 = (TextMessage)cons.receive(1000);         assertNull(r3);             }      finally      {         if (conn != null)         {            conn.close();         }         if (conn2 != null)         {            conn2.close();         }      }         }