vendredi 26 juin 2015

FacesServlet returning Null pointer exception

I have tried all the solutions but I can´t fix this problem.

The classes that I have are:

-User (Entity)

-Negocio (Local interface EJB)

-NegocioImpl (Stateless EJB with PersistenceContext)

-Registro (Little @ManagedBean @RequestScoped to insert Users in DB with @PostConstruct init() method and @Inject atributte of Negocio and another atributte of User)

Here's the code of Registro:

import modelo.User;
import negocio.Negocio;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;

@ManagedBean
@RequestScoped
public class Registro {

@Inject
private Negocio negocio;

private User usuario;

@PostConstruct
public void init(){
    usuario = new User();
}

public User getUsuario() {

    return usuario;
}

public void setUsuario(User usuario) {

    this.usuario = usuario;
}

public void insertarUsuario(){
    negocio.sayHelloFromServiceBean(usuario);
}

public void saluda(){
    negocio.hola();
  }
}

Everything is apparently right. But when I test the application I have this exception:

http://ift.tt/1REjqm5

Here is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://ift.tt/19L2NlC"
     xmlns:xsi="http://ift.tt/ra1lAU"
     xsi:schemaLocation="http://ift.tt/19L2NlC http://ift.tt/1drxgYl"
     version="3.1">
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>

Here is my faces-config.xml file:

<?xml version='1.0' encoding='UTF-8'?>

<faces-config xmlns="http://ift.tt/nSRXKP"
          xmlns:xsi="http://ift.tt/ra1lAU"
          xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1cpkFEe"
          version="2.0">
</faces-config>

Im using JSF 2.0, EJB 3.1, JBoss 7.1.1 Final, Java EE 6 with Intellij IDEA as IDE.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire