2 Replies Latest reply on Sep 1, 2009 1:36 AM by Jun Li

    How to start transaction on em retrieved from jndi?

    Jun Li Newbie

      Hi all,


      I'm using JBoss and exposing entity manager factory in globle jndi, so that any POJO can use it.


      So, I have the following in persistence.xml



      <property name="jboss.entity.manager.factory.jndi.name" value="java:/managerFactory"/>





      Then in pojo I get the factory from Jndi lookup and create an em from it.


      But when I try to persist something from the em, it says no transaction, and if I  use em.getTransaction().begin(), it says something like, it's a JTA em can't start transaction.


      How do I persist from the entity manager that was retrieved from the Jndi then? A further question is, if there is an existing EJB tx available, is that possiable to get it propagated into this em?


      Thx.