I'm getting the error:
com.sun.faces.mgbean.ManagedBeanCreationException: No se puede crear el bean administrado loginBean.
Se han encontrado los problemas siguientes:- No se encuentra el bean o la clase de propiedad com.pf.mbean.loginBean para el bean administrado loginBean.
In english it would be something like:
Cannot create management bean loginBean there are found following troubles: Cannot find bean or property class com.pf.mbean.loginBean for the managment bean loginBean
My bean is the following:
package com.pf.mbean;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.http.HttpSession;
import org.primefaces.context.RequestContext;
@ManagedBean(name="loginBean")
public class loginBean implements Serializable
{
private static final long serialVersionUID = -2152389656664659476L;
private String nombre;
private String clave;
private boolean logeado = false;
public boolean estaLogeado()
{
return logeado;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getClave() {
return clave;
}
public void setClave(String clave) {
this.clave = clave;
}
public boolean isLogeado() {
return logeado;
}
public void setLogeado(boolean logeado) {
this.logeado = logeado;
}
public void login(ActionEvent actionEvent)
{
RequestContext context = RequestContext.getCurrentInstance();
FacesMessage msg = null;
if (nombre != null && nombre.equals("admin") && clave != null && clave.equals("admin"))
{
logeado = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido: ", nombre);
}
else
{
logeado = false;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error","Credenciales no válidas");
}
FacesContext.getCurrentInstance().addMessage(null, msg);
context.addCallbackParam("estaLogeado", logeado);
if (logeado)
context.addCallbackParam("view", "gauge.xhtml");
}
public void logout()
{
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.invalidate();
logeado = false;
}
}
And my faces-config.xml I have set the following configuration:
<managed-bean>
<managed-bean-name>loginBean</managed-bean-name>
<managed-bean-class>com.pf.mbean.loginBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope> </managed-bean>
In my login.xhtml I'm refer to the bean at this way:
<p:inputText value="#{loginBean.nombre}" id="username"
required="true" label="username" />
<h:outputLabel for="password" value="Clave:" />
<p:password value="#{loginBean.clave}" id="password" required="true"
label="password" />
But I have no idea why the class has not been found, any idea?