0 Replies Latest reply on May 25, 2011 9:11 AM by couse1

    java.lang.NullPointerException on a treenode

    couse1 Newbie

      Hi,

       

      I'm using richfaces 4.0, jsf 2.0 and when i  click on a node in tree, i've got this error :

       

      14:58:14,227 GRAVE [org.richfaces.log.Context] java.lang.NullPointerException: javax.faces.FacesException: java.lang.NullPointerException

          at org.richfaces.component.UIDataAdaptor.invokeOnComponent(UIDataAdaptor.java:1124) [:4.0.0.Final]

          at org.richfaces.renderkit.TreeRendererBase.decode(TreeRendererBase.java:208) [:4.0.0.Final]

          at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:791) [:2.0.3-]

          at org.richfaces.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:824) [:4.0.0.Final]

          at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:55) [:4.0.0.Final]

          at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337) [:4.0.0.Final]

          at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1235) [:4.0.0.Final]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

          at javax.faces.component.UIForm.visitTree(UIForm.java:331) [:2.0.3-]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

          at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:249) [:4.0.0.Final]

          at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:229) [:4.0.0.Final]

          at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:208) [:4.0.0.Final]

          at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:918) [:2.0.3-]

          at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:74) [:2.0.3-]

          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-]

          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-]

          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

          at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]

          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]

          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]

          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]

          at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]

          at java.lang.Thread.run(Unknown Source) [:1.6.0_24]

      Caused by: java.lang.NullPointerException

          at org.richfaces.model.ClassicTreeNodeDataModelImpl.setupChildContext(ClassicTreeNodeDataModelImpl.java:49) [:4.0.0.Final]

          at org.richfaces.model.ClassicTreeNodeDataModelImpl.setupChildContext(ClassicTreeNodeDataModelImpl.java:35) [:4.0.0.Final]

          at org.richfaces.model.NodesTreeSequenceKeyModel.setupKey(NodesTreeSequenceKeyModel.java:47) [:4.0.0.Final]

          at org.richfaces.model.TreeSequenceKeyModel.setRowKey(TreeSequenceKeyModel.java:49) [:4.0.0.Final]

          at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:277) [:4.0.0.Final]

          at org.richfaces.component.UIDataAdaptor.invokeOnComponent(UIDataAdaptor.java:1111) [:4.0.0.Final]

          ... 40 more

       

       

      My xhtml file :

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

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:a4j="http://richfaces.org/a4j"

            xmlns:rich="http://richfaces.org/rich"

            xmlns:f="http://java.sun.com/jsf/core"

            xmlns:ui="http://java.sun.com/jsf/facelets">

       

      <h:head></h:head>

      <body>

          <h:panelGrid columns="2" columnClasses="top,top" width="60%">

              <f:facet name="header">

                   Referentiel Batiment

              </f:facet>

       

              <h:form>

                  <rich:tree id="tree" nodeType="#{node.type}" var="node"

                                  value="#{refItemController.myTree}" toggleType="client"

                                  selectionType="ajax"

                                  selectionChangeListener="#{refItemController.selectionChanged}">

                      <rich:treeNode type="arbo" iconCollapsed="/images/tree/Maison.png" iconExpanded="/images/tree/Maison.png"  iconLeaf="/images/tree/Maison.png">

                          <h:outputText value="#{node.name}"/>

                      </rich:treeNode>

                  </rich:tree>

              </h:form>

       

              <a4j:outputPanel ajaxRendered="true" layout="block">

                  <rich:panel header="Détails">

                      <h:outputText value="Nom:" />

                      <h:outputText value="#{refItemController.myTree.name}" />

                  </rich:panel>

              </a4j:outputPanel>

          </h:panelGrid>

      </body>

      </html>

       

      My managed bean :

      package com.galhauban.patrimoine.batiment;

       

      import java.io.Serializable;

      import javax.ejb.EJB;

      import javax.faces.bean.ManagedBean;

      import javax.faces.bean.RequestScoped;

      import javax.faces.bean.SessionScoped;

      import javax.inject.Named;

       

      //@Named("batimentController")

      @ManagedBean(name="batimentController")

      @SessionScoped

      public class BatimentController implements Serializable {

         

          private static final long serialVersionUID = 1L;

          private int identifiant;

          @EJB

          private BatimentLocal building;

          private BatimentEntity batiment;

         

          public BatimentController(){};

         

          public BatimentLocal getBuilding() {

              return building;

          }

       

          public void setBuilding(BatimentLocal building) {

              this.building = building;

          }

       

          public BatimentEntity getBatiment() {

              return batiment;

          }

       

          public void setBatiment(BatimentEntity batiment) {

              this.batiment = batiment;

          }

         

          public int getIdentifiant() {

              return identifiant;

          }

       

          public void setIdentifiant(int identifiant) {

              this.identifiant = identifiant;

          }

         

          public String doSearch() {

              try {

                  System.out.println("Entre dans doSearch identifiant: "+identifiant );

                  batiment = building.searchBatiment(identifiant);

                  System.out.println("Entre dans doSearch : "+batiment.getNom() );

                  return "building.found";

              }

              catch (Exception ex){

                  System.out.println("pb : " + ex.getMessage());

                  return null;

              }

             

          }

      }

       

      thanks for your help

      johan JOSEPH