1 Reply Latest reply on May 27, 2010 12:57 AM by ssamayoagt

    Simple JSF2 + CDI + JPA + GlassFish 3 dont work

      Im doing some very simple test with JSF2 + CDI + JPA + GlassFish 3, this is my backing bean:

      package test;

      import java.io.Serializable;

      import javax.enterprise.context.RequestScoped;
      import javax.inject.Named;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      import entidad.Cliente;

      public class Test1 implements Serializable {

           private static final long serialVersionUID = -8891397705401579378L;

           public String getHolaMundo() {
                return "Hola Mundo !!";
           @PersistenceContext(unitName="test1") EntityManager em;

           public void crearCliente() {
                System.out.println("crearCliente() " + em.toString());
                Cliente c = new Cliente();
                c.setNombre("Hola mundo !!");

      With a button in a JSF page I invoke "crearCliente()" but I get javax.persistence.TransactionRequiredException

      Do I have to use EJB instead of pojo for backing bean?

      What Im missing?