tags:

views:

28

answers:

2

Hello, fellow Java warriors!
I have this managed bean to handle the Rede (Network) entity related operations called RedesBean (NetworksBean). I have three pages to insert a new network: redes/nova.xhtml (new.xhtml), which is basically a series of input fields to insert the Network properties and a commandButton which invokes a cadastraNova() (createNew()) method which validates the input and calculates some values. The cadastraNova() method then returns to another page, redes/confirma.xhtml (confirm.xhtml) which shows the value of each property and the calculated values, asks for user confirmation and then invokes another method, cadastraRede() (createNetwork()) to persist the Network to database via JPA.
When I use @RequestScoped, the values are not preserved between the second and third views. When I use @SessionScoped, the values are preserved, but I think @SessionScoped-ing this is a bit too much. So, after a bit of Googling, I found this @ViewScoped annotation which I think fits perfectly to my case. But here's the issue: after I click the commandButton in the first view (redes/nova.xhtml), I get a NullPointerExcetption, caused by a EvaluationException. The cadastraNova() method is invoked, but it fails to evaluate the bean property values. The relevant code is posted below:

RedesBean.java

package br.cefetmg.ccc.gerir.web;

// suppressed imports

/**
 * Bean to manage network and subnetwork views
 * @author Arthur Alkmim
 *
 */
@ManagedBean(name="redes")
@ViewScoped
public class RedesBean implements Serializable{
 @EJB
 transient RedeDAO redeDAO;

 private static final Logger logger = Logger.getLogger("br.cefetmg.ccc.gerir.web.RedesBean");

 // attributes, suppressed

 // getters and setters, suppressed

 // the "broken" method
 public String cadastraNova(){
  logger.info("Method cadastraNova() successfully invoked");
  // verifica se a rede não já existe
  if(redeDAO.buscaPorId(ipBase) != null){
   FacesContext.getCurrentInstance().addMessage("Rede já existente", new FacesMessage("Já existe uma rede com esse IP"));
   return FacesContext.getCurrentInstance().getViewRoot().getViewId();
  }
  calculaAtributos();
  // verifica se o range de lease é válido
  if(!validaRange())
   // volta para a página de cadastro
   return FacesContext.getCurrentInstance().getViewRoot().getViewId();
  return "/redes/confirma";
 }
 // other suppressed methods
}

redes/nova.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ccc="http://java.sun.com/jsf/composite/compz"&gt;
<ui:composition template="/resources/estilo/template.xhtml">
 <f:loadBundle var="msg" basename="br.cefetmg.ccc.gerir.web.AppResources"/>
 <ui:define name="title">Nova rede</ui:define>
 <ui:define name="content">
  <h:form id="form">
   <h3>Principal</h3>
   <h:panelGrid columns="2" id="principal">
    <h:outputText value="Nome da rede" />
    <h:inputText value="#{redes.nome}" id="nome" />

    <h:outputText value="IP" />
    <h:panelGroup id="ip">
     <ccc:inputOneIP ip="#{redes.ipBase}" id="ipBase" />
     /
     <h:inputText value="#{redes.cidr}" size="2" id="cidr" validatorMessage="O CIDR deve estar entre 0 e 32">
      <f:validateLongRange minimum="0" maximum="32"/>
     </h:inputText>
    </h:panelGroup>
   </h:panelGrid>
   <h3>Servidores</h3>
   <h:panelGrid columns="2">
    <h:outputText value="Router" />
    <ccc:inputManyIP ip="#{redes.routers}" id="routers" />

    <h:outputText value="DNS" />
    <ccc:inputManyIP ip="#{redes.dns}" id="dns" />

    <h:outputText value="Netbios" />
    <ccc:inputManyIP ip="#{redes.netbios}" id="netbios" />
   </h:panelGrid>
   <h3>Lease</h3>
   <h:panelGrid columns="2">
    <h:outputText value="Tempo default" />
    <h:inputText value="#{redes.leaseDefault}" id="leaseDefault">
     <f:validateLongRange minimum="0" />
    </h:inputText>

    <h:outputText value="Tempo máximo" />
    <h:inputText value="#{redes.leaseMax}" id="leaseMax">
     <f:validateLongRange minimum="0" />
    </h:inputText>

    <h:outputText value="Início da faixa" />
    <ccc:inputOneIP ip="#{redes.rangeMin}" id="rangeMin" />

    <h:outputText value="Fim da faixa" />
    <ccc:inputOneIP ip="#{redes.rangeMax}" id="rangeMax" />
   </h:panelGrid>
   <h:commandButton action="#{redes.cadastraNova}" value="Cadastra"/>
  </h:form>
 </ui:define>
</ui:composition>
</html>

redes/confirma.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ccc="http://java.sun.com/jsf/composite/compz"&gt;

<ui:composition template="/resources/estilo/template.xhtml">
 <f:loadBundle var="msg" basename="br.cefetmg.ccc.gerir.web.AppResources"/>
 <ui:define name="title">Nova rede</ui:define>
 <ui:define name="content">
  <h:form id="form">
   Nome: <h:outputText value="#{redes.nome}" /><br />
   <ccc:outputOneIP ip="#{redes.ipBase}" />/<h:outputText value="#{redes.cidr}" />
   (<ccc:outputOneIP ip="#{redes.ipMin}" /> a <ccc:outputOneIP ip="#{redes.ipMax}" />)<br />
   Broadcast em: <ccc:outputOneIP ip="#{redes.broadcast}" /> <br />
   Máscara de rede: <ccc:outputOneIP ip="#{redes.netmask}" /><br />
   Roteadores: <ccc:outputManyIP ip="#{redes.routers}" /><br />
   Servidores de DNS: <ccc:outputManyIP ip="#{redes.dns}"/><br />
   Servidores netbios: <ccc:outputManyIP ip="#{redes.netbios}"/><br />
   Tempo de lease padrão: <h:outputText value="#{redes.leaseDefault}"/><br />
   Tempo de lease máximo: <h:outputText value="#{redes.leaseMax}"/><br />
   Range do lease: <ccc:outputOneIP ip="#{redes.rangeMin}" /> a <ccc:outputOneIP ip="#{redes.rangeMax}" /><br />
   <br />
   Estes dados estão corretos?
   <h:commandButton action="#{redes.cadastraRede}" value="Sim" />
   <h:commandButton action="#{redes.cancelaCadastro}" value="Não" />
  </h:form>
 </ui:define>
</ui:composition>
</html>

The server log

[#|2010-10-27T13:55:07.713-0200|INFO|glassfish3.0.1|br.cefetmg.ccc.gerir.web.RedesBean|_ThreadID=31;_ThreadName=Thread-1;|Method cadastraNova() successfully invoked|#]

[#|2010-10-27T13:55:07.713-0200|SEVERE|glassfish3.0.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=31;_ThreadName=Thread-1;|java.lang.NullPointerException
javax.faces.el.EvaluationException: java.lang.NullPointerException
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
 at javax.faces.component.UICommand.broadcast(UICommand.java:311)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
 at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
 at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
 at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
 at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
 at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
 at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
 at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
 at br.cefetmg.ccc.gerir.web.RedesBean.cadastraNova(RedesBean.java:231)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
 ... 32 more
|#]

[#|2010-10-27T13:55:07.714-0200|WARNING|glassfish3.0.1|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=31;_ThreadName=Thread-1;|#{redes.cadastraNova}: java.lang.NullPointerException
javax.faces.FacesException: #{redes.cadastraNova}: java.lang.NullPointerException
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:114)
 at javax.faces.component.UICommand.broadcast(UICommand.java:311)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
 at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
 at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
 at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
 at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
 at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
 at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
 at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
 ... 31 more
Caused by: java.lang.NullPointerException
 at br.cefetmg.ccc.gerir.web.RedesBean.cadastraNova(RedesBean.java:231)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
 ... 32 more
|#]

[#|2010-10-27T13:55:07.715-0200|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=31;_ThreadName=Thread-1;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.el.EvaluationException: java.lang.NullPointerException
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
 at javax.faces.component.UICommand.broadcast(UICommand.java:311)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
 at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
 at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
 at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
 at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
 at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
 at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
 at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
 at br.cefetmg.ccc.gerir.web.RedesBean.cadastraNova(RedesBean.java:231)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
 ... 32 more
|#]

[#|2010-10-27T13:55:07.715-0200|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=31;_ThreadName=http-thread-pool-8080-(2);|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.el.EvaluationException: java.lang.NullPointerException
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
 at javax.faces.component.UICommand.broadcast(UICommand.java:311)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
 at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
 at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
 at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
 at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
 at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
 at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
 at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
 at br.cefetmg.ccc.gerir.web.RedesBean.cadastraNova(RedesBean.java:231)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
 ... 32 more
|#]

[#|2010-10-27T13:55:07.715-0200|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=31;_ThreadName=http-thread-pool-8080-(2);|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.el.EvaluationException: java.lang.NullPointerException
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
 at javax.faces.component.UICommand.broadcast(UICommand.java:311)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
 at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
 at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
 at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
 at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
 at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
 at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
 at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
 at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
 at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
 at br.cefetmg.ccc.gerir.web.RedesBean.cadastraNova(RedesBean.java:231)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
 ... 32 more
|#]

So, as you guys can see, the method is really being invoked by the logger output in the log first line. The method fails when it evaluates a property which is probably not being updated. So, how to fix?

+2  A: 

The only which can be null in the method snippet you've shown as far is redeDAO. Since it's marked transient I think that the server is configured to store views/sessions on disk immediately (by serialization) instead of being kept in memory all the time. Anything which is declared transient will be lost during serialization and JSF can't reinject it for you after deserialization.

I'd suggest to make the @EJB non-transient (just implement Serializable) and retry.

BalusC
It gave me a java.io.NotSerializableException: com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate, even though I made the bean serializable. But I don't think it has anything to do with the EJB, because if I try to print any of the attributes through the Logger, it gives me exactly the same exception from the first post.
Arthur Alkmim