I'm doing a HelpDesk chat project with JSF 2.0 and Primefaces, but an error is thrown when I try to connect the Attendant
or user in the chat.
In atendente.xhtml
and index.xhtml
has a form that sends the information to AtendenteBean.java
and UsuarioBean.java
, respectively.
Attendant.jsp:
<p:panel header="Login do Atendente" rendered="#{not atendenteMB.autenticado}">
<h:outputLabel for="txtNome" value="Login:"/>
<br/>
<h:inputText id="txtNome" value="#{atendenteMB.atendente.login}"/>
<br/>
<h:outputLabel for="txtSenha" value="Senha:"/>
<br/>
<h:inputSecret id="txtSenha" value="#{atendenteMB.atendente.senha}"/>
<br/>
<h:commandButton action="#{atendenteMB.signIn}" value="Entrar"/>
<br/>
</p:panel>
AttendantBean.java:
@ManagedBean(name="atendenteMB")
@SessionScoped
public class AtendenteBean implements Serializable{
public AtendenteBean(){
}
private static final long serialVersionUID = 1L;
@ManagedProperty(value="#{localizadorMB}")
private LocalizadorBean gerenciarLocalizador;
@ManagedProperty(value="#{chatMB}")
private ChatBean chat;
private Atendente atendente = new Atendente();
private boolean autenticado;
public void signIn(){
if(atendente.getLogin().equals(atendente.getSenha())){
gerenciarLocalizador.getGerenciador().addAtendente(atendente);
setAutenticado(true);
}
else{
FacesMessage msgm = new FacesMessage("Login ou Senha inválidos.");
FacesContext.getCurrentInstance().addMessage(null, msgm);
}
}
Error generated when I click the Send button.
HTTP Status 500 - java.lang.NullPointerException
type Exception report
message
---
java.lang.NullPointerException
description
---
The server encountered an internal error that prevented it from fulfilling this request.
exception
---
javax.servlet.ServletException: java.lang.NullPointerException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
---
javax.faces.el.EvaluationException: java.lang.NullPointerException
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpress ionAdapter.java:101)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
---
java.lang.NullPointerException
managedbean.AtendenteBean.signIn(AtendenteBean.java:34)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.el.parser.AstValue.invoke(AstValue.java:278)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpress ionAdapter.java:87)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.
If you need more details, just comment.