I have a big very problem. I'm using Netbeans IDE 7.4 with Java EE 6. Whenever I try to persist an Entitie. It throws me
Advertencia: #{controlador.save}: javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB javax.faces.FacesException: #{controlador.save}: javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB........... Caused by: java.lang.NullPointerException
But whenever I try to use SessionScoped and others Scopes. It doesn't throw me and error. Here is the code of my farcade.
@Stateless
public class Users1Facade extends AbstractFacade<Users1> {
@PersistenceContext(unitName = "PruebaEJBPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
public Users1Facade() {
super(Users1.class);
}
@Override
public void create(Users1 entity) {
getEntityManager().persist(entity);
}
}
And Here is the code of my Controler
@Named
@ConversationScoped
public class Controlador implements Serializable{
private Users1 user=new Users1();
@EJB
private Users1Facade facade;
@PostConstruct
public void init()
{
user=new Users1();
user.setName("qqq");
user.setApellido("rwerwe");
user.setId(32);
}
public String a()
{
facade.create(user);
return "index";
}
This error only throws me with Conversation Scoped. And I need to use that scope.It's damn annoying.
Aucun commentaire:
Enregistrer un commentaire