Discussions

EJB programming & troubleshooting: Combining CMT MDB and BMT Stateless Session Bean-> possible?

  1. Hi all. Does anyone know, is it possible to combine container managed transaction MDB and bean manager transaction stateless session bean? At first I used BMT MDB cause behind code performs several commits along business process. Problem is that if database is locked message is consumed and rollback won't take it back to queue. So I switched to CMT MDB that calls BMT Session bean. But when I perform rollback on BMT i get following error from container: ServerSession W WMSG0031E: Exception processing JMS Message for MDB ContainerListener, JMSDestination jms/queueIN2 : javax.ejb.TransactionRolledbackLocalException: ; nested exception is: com.ibm.websphere.csi.CSITransactionRolledbackException com.ibm.websphere.csi.CSITransactionRolledbackException at com.ibm.ejs.csi.BeanManaged.postInvoke(BeanManaged.java:310) at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581) at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3910) at hr.vestigo.framework.remote.jms.EJSLocalStatelessBMTAccessor_6099dba2.execute(EJSLocalStatelessBMTAccessor_6099dba2.java:42) at hr.vestigo.modules.rba.interfaces.jms.AbstractContainerMQListener.onMessage(AbstractContainerMQListener.java:32) at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:302) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63) at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:271) at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:240) at com.ibm.mq.jms.MQSession.run(MQSession.java:1592) at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:970) at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:891) at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:656) at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:623) at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37) at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:96) at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132) at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:481) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469) javax.ejb.TransactionRolledbackLocalException: ; nested exception is: com.ibm.websphere.csi.CSITransactionRolledbackException at com.ibm.ejs.csi.BeanManaged.postInvoke(BeanManaged.java:310) at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581) at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3910) at hr.vestigo.framework.remote.jms.EJSLocalStatelessBMTAccessor_6099dba2.execute(EJSLocalStatelessBMTAccessor_6099dba2.java:42) at hr.vestigo.modules.rba.interfaces.jms.AbstractContainerMQListener.onMessage(AbstractContainerMQListener.java:32) at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:302) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63) at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:271) at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:240) at com.ibm.mq.jms.MQSession.run(MQSession.java:1592) at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:970) at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:891) at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:656) at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:623) at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37) at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:96) at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132) at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:481) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469) Caused by: com.ibm.websphere.csi.CSITransactionRolledbackException does anybody have any clue what am I doing wrong? thanx, Ante
  2. You can call a BMT bean from a CMT bean, but your CMT bean's transaction will not be propagated to your BMT. Check whether your BMT throws any EJBException in the scenarios where you get this error. Coz when your target bean throws a EJBException back to your local client (when client is in tx), the container might throw the EJBException back as a javax.ejb.TransactionRolledbackLocalException. Make sure your code doesn't fall into these categories. other wise you have to handle accordingly. Subramanian, Kumar kumar at eminenttech dot com J2EE Architect Eminent Technology Solutions (ETS) Software / Portals / Alfresco / Outsourcing / Proteomics www.eminenttech.com
  3. My plan was not to propagate CMT to Session BMT. I want to keep these transactions separated. Session BMT uses transaction to perform 3 operations: 1. log incoming message into DB system as accepted 2. perform business process and DB writing 3. log sent reply message and pair it with incoming request 1 and 3 operation must perform with commit cause I need to have track of message in system. 2 operation should perform commit only if business request is valid. In other case it should do rollback to clean account and balance half-stages that could be stale. Is it possible to perform rollback in target bean and have commit in CMT MDB? /Ante
  4. It is possible. EJB supports only flat transactions. In your case the CMT bean's transaction has no knowledge about your BMT beans' tx. You can try to setRollbackOnly and avoid calling rollback directly in your BMT's UserTransaction. Otherwise you can try to catch & supress the TransactionRolledbackLocalException thrown by the container as a result of your BMT's rollback in your MDB. But you should be convinced your BMT bean is not throwing any informative system exception that you do not wish to ignore/supress. Good Luck! Subramanian, Kumar kumar at eminenttech dot com J2EE Architect Eminent Technology Solutions (ETS) Software / Portals / Alfresco / Outsourcing / Proteomics www.eminenttech.com
  5. thanks a lot! /Ante