JBossXAResource res = (JBossXAResource)sess.getXAResource();
MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
   public void test2PCReceiveCommit() throws Exception   {      if (ServerManagement.isRemote()) return;                  XAConnection conn = null;      Connection conn2 = null;            try      {         conn2 = cf.createConnection();         conn2.start();         Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageProducer prod  = sessProducer.createProducer(queue);         Message m = sessProducer.createTextMessage("XATest1");         prod.send(m);         m = sessProducer.createTextMessage("XATest2");         prod.send(m);                  conn = cf.createXAConnection();         conn.start();                  tm.begin();                  XASession sess = conn.createXASession();         JBossXAResource res = (JBossXAResource)sess.getXAResource();         res.setPreventJoining(true);                  XAResource res2 = new DummyXAResource();                  Transaction tx = tm.getTransaction();         tx.enlistResource(res);         tx.enlistResource(res2);                  MessageConsumer cons = sess.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());                  tx.commit();                  //New tx         tm.begin();         tx = tm.getTransaction();         tx.enlistResource(res);         tx.enlistResource(res2);                  Message m3 = cons.receive(1000);                  assertNull(m3);                  tm.commit();               }      finally      {         if (conn != null)         {            conn.close();         }         if (conn2 != null)         {            conn2.close();         }      }         }