显示java.lang.NullPointerException

时间:2014-02-08 15:45:05

标签: jsf jsf-2 nullpointerexception

我正在做一个项目HelpDesk与jsf 2.0和primefaces聊天,但是当我尝试在聊天中连接Attendant或User时会产生错误。

在atendente.xhtml和index.xhtml中有一个表单,它将信息发送到AtendenteBean.java和UsuarioBean.java文件。

这是一个页面Atendente.jsp:

<p:panel header="Login of Atendant" 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="Password:"/>
         <br/>

         <h:inputSecret id="txtSenha" value="#{atendenteMB.atendente.senha}"/>
         <br/>
         <h:commandButton action="#{atendenteMB.signIn}" value="Login"/>
         <br/>

       </p:panel>

这是java文件AtendenteBean.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);
    }
}

...
}

请查看我按下“登录”按钮时产生的错误。

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.

请,我需要帮助才能解决此错误。 如果需要更多细节,请进行沟通。

0 个答案:

没有答案