Hi, 

I have the following 2 classes. I get TransactionRequiredException  only
when I have @Asynchronous on stateless EJB. If I remove the annotation,
everything works. I'm on Tomee 1.6 snapshot from a couple of weeks ago. 

Is this related to a bug in @Asynchronous? Or because I load info object in
a non-EJB class, then try to use it in stateless EJB? Or something else?


@ViewScoped
@Named
public class EditInfoComponent{

       @Inject
       private AsyncQueryProcessor asyncQuery;

        @Inject
        private EntityManager entityManager;   

      @Transactional   //from Deltaspike
      public void handleChanges(){
             //get info from entityManager
            asyncQuery.sendNotifications(info);
     }
}


@Stateless
public class AsyncQueryProcessor implements Serializable {

        @PersistenceContext(unitName = PersistenceConfiguration.UNIT_NAME)
        private EntityManager entityManager;

         @Asynchronous       //works with this annotation removed
         public void sendNotifications(Info info){
           
            if (info.isNew()){
                  Notification notif = new Notification();
                  entityManager.persist(notif);
            }else{
                  Notification notif =
entityManager.find(Notification.class, info.getNotificationId());
                  notif.setSomeFlags(true);
                  entityManager.merge(notif); //get
TransactionRequiredException 
            }
         }
}

A class to produce EntityManager:

public class PersistenceConfiguration implements Serializable {
        @PersistenceUnit(unitName = UNIT_NAME)
        private EntityManagerFactory entityManagerFactory;

        @Produces
        @RequestScoped
        @Default
        public EntityManager createEntityManager() {
                return entityManagerFactory.createEntityManager();
        }

         public void closeEntityManager(@Disposes final EntityManager em) {
                if (em.isOpen()) 
                {
                        em.close();
                }
        }
}



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Asynchronous-And-TransactionRequiredException-tp4664007.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to