JBossXAResource res = (JBossXAResource)sess.getXAResource();
MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
   public void test2PCSendCommit() throws Exception   {      if (ServerManagement.isRemote()) return;            XAConnection conn = null;      Connection conn2 = null;            try      {               conn = cf.createXAConnection();                  tm.begin();                  XASession sess = conn.createXASession();                  JBossXAResource res = (JBossXAResource)sess.getXAResource();                  XAResource res2 = new DummyXAResource();                  //To prevent 1PC optimization being used         res.setPreventJoining(true);                  Transaction tx = tm.getTransaction();         tx.enlistResource(res);         tx.enlistResource(res2);                  MessageProducer prod = sess.createProducer(queue);         prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);         Message m = sess.createTextMessage("XATest1");         prod.send(queue, m);         m = sess.createTextMessage("XATest2");         prod.send(queue, m);                  tx.commit();                  conn2 = cf.createConnection();         conn2.start();         Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageConsumer cons = sessReceiver.createConsumer(queue);         TextMessage m2 = (TextMessage)cons.receive(1000);         assertNotNull(m2);         assertEquals("XATest1", m2.getText());         m2 = (TextMessage)cons.receive(1000);         assertNotNull(m2);         assertEquals("XATest2", m2.getText());      }      finally      {         if (conn != null)         {            conn.close();         }         if (conn2 != null)         {            conn2.close();         }      }   }