Hi,

I think there is an error in the code generated by NetBeans to use an 
EntityManager.

I create a session Beans stateless.

In this session bean, Alt-Insert > Use Entity Manager...

The inserted code use UserTransaction when the bean is not annotated with
@TransactionManagement( TransactionManagementType.BEAN):

    @PersistenceContext(unitName = "samplePU")
    private EntityManager em;
    @Resource
    private javax.transaction.UserTransaction utx;

    public void persist(Object object) {
        try {
            utx.begin();
            em.persist(object);
            utx.commit();
        } catch (Exception e) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception 
caught", e);
            throw new RuntimeException(e);
        }
    }

Normally the transaction should be managed by the container without using 
UserTransaction.

Richard




Reply via email to