JBossXAResource res1 = (JBossXAResource)sess1.getXAResource();
MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
   public void testMultipleSessionsOneTxRollbackAcknowledgeForceFailureInCommit() 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);         m = sessProducer.createTextMessage("jellyfish3");         prod.send(m);         m = sessProducer.createTextMessage("jellyfish4");         prod.send(m);                           conn = cf.createXAConnection();         conn.start();                     tm.begin();                  XASession sess1 = conn.createXASession();         JBossXAResource res1 = (JBossXAResource)sess1.getXAResource();         DummyXAResource res2 = new DummyXAResource(true);         res1.setPreventJoining(true);                           Transaction tx = tm.getTransaction();         tx.enlistResource(res1);         tx.enlistResource(res2);                  //Receive the messages, two on each consumer         MessageConsumer cons1 = sess1.createConsumer(queue);         TextMessage r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish1", r1.getText());                  r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish2", r1.getText());                  r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish3", r1.getText());                  r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish4", r1.getText());                           cons1.close();                                    //try and commit - and we're going to make the dummyxaresource throw an exception on commit,         //which should cause rollback to be called on the other resource         try         {            tx.commit();         }         catch (Exception e)         {            //We should expect this         }                  Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageConsumer cons = sess.createConsumer(queue);         conn2.start();                   TextMessage r3 = (TextMessage)cons.receive(1000);                  assertNotNull(r3);         assertEquals("jellyfish1", r3.getText());                  r3 = (TextMessage)cons.receive(1000);                  assertNotNull(r3);         assertEquals("jellyfish2", r3.getText());         //log.info(r3.getText());                  TextMessage r4 = (TextMessage)cons.receive(1000);                  assertNotNull(r4);         assertEquals("jellyfish3", r4.getText());         //log.info(r4.getText());                  r4 = (TextMessage)cons.receive(1000);                  assertNotNull(r4);         assertEquals("jellyfish4", r4.getText());               }      finally      {         if (conn != null)         {            conn.close();         }         if (conn2 != null)         {            conn2.close();         }      }         }