0 Replies Latest reply on May 16, 2009 4:27 PM by Naresh Bhatia

    Using seam managed transactions in a Spring MessageListener

    Naresh Bhatia Newbie

      I am using a Spring bean to listen to JMS messages. The Spring bean in turn calls a Seam component which accesses the database and uses Seam managed transactions to do so. Here's the code (OrderListener is the MessageListener which is a Spring bean. It calls OrderRepository which is a Seam component):

      public class OrderListener implements MessageListener {
          private OrderRepository orderRepository;
          public void onMessage(Message message) {
      public class JpaOrderRepository {
          @In private EntityManager entityManager;
          public void persist(Order order) {

      However the call to orderRepository.persist() results in a IllegalStateException stating that there is No such transaction!:

      java.lang.IllegalStateException: [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] No such transaction!
           at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.setRollbackOnly(BaseTransaction.java:189)
           at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.setRollbackOnly(BaseTransactionManagerDelegate.java:135)
           at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:432)
           at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:587)
           at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
           at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:218)
           at org.jboss.seam.persistence.EntityManagerProxy.persist(EntityManagerProxy.java:137)
           at myApp.OrderRepository.persist(OrderRepository.java:56)

      Is there any way to have my Spring MessageLister participate in Seam managed transactions? I read through section 27.6 of the Seam reference manual (Using a Seam Managed Persistence Context in Spring) and set up a seamEntityManagerFactory, but I don't readily see how that would make my JMS MessageListener start a Seam managed transaction.

      Any help would be much appreciated.