Topic
  • 1 reply
  • Latest Post - ‏2010-05-03T09:48:51Z by allam
allam
allam
2 Posts

Pinned topic Can't enlist XAResource in websphere

‏2010-05-03T09:46:59Z |
Hi All,

I am trying to enlist an XAResource in websphere in my Resource Adapter. I encounter the following exception:

"illegal attempt to enlist a 2pc xaresource"

I tried enlisting the XAResource which implements javax.transaction.xa.XAResource. I get the same exception.

Here is the snippet:

web.DummyXAResource dummy = new web.DummyXAResource(); //Implements javax.transaction.xa.XAResource
javax.transaction.TransactionManager tm = com.ibm.ws.Transaction.TransactionManagerFactory.getTransactionManager();
javax.transaction.UserTransaction ux = (javax.transaction.UserTransaction)
(new javax.naming.InitialContext()).lookup("java:comp/UserTransaction");

tm.begin();
javax.transaction.Transaction t = tm.getTransaction();
out.print("Before enlist Resource called ...");
t.enlistResource(dummy); // This line throws the error
out.print("After enlist Resource called ...");
tm.commit();

I tried the above with ux.begin() & ux.end() also but got the same error.

Can any one let me know how an XAResource is enlisted in WebSphere?

Regards,
Vam
  • allam
    allam
    2 Posts

    Re: Can't enlist XAResource in websphere

    ‏2010-05-03T09:48:51Z  
    I get the following exception:

    java.lang.IllegalStateException: Illegal attempt to enlist a 2PC XAResource at com.ibm.ws.tx.jta.TransactionImpl.enlistResource(TransactionImpl.java:1697) at _ibmjsp._Test2._jspService(_Test2.java:113) at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1583) at