3 Replies Latest reply on Jun 22, 2009 10:26 AM by Stephan B

    enicmatic NullPointerException in rich:tree

    Stephan B Newbie

      Hi everyone,

      I'm facing a strange error I try to fight now and then for few weeks now.
      It occurs when I click a button I aligned in the same row as a quite deeply nested element in my rich:tree.

      I can't exactly determine what's the cause for it, because no code of my own directly appears in the stack trace.

      java.lang.NullPointerException
       at org.richfaces.model.ListRowKey.getCommonPathLength(ListRowKey.java:224)
       at org.richfaces.model.TreeDataModel.locateTreeNode(TreeDataModel.java:200)
       at org.richfaces.model.TreeDataModel.locateTreeNode(TreeDataModel.java:187)
       at org.richfaces.model.TreeDataModel.doWalk(TreeDataModel.java:106)
       at org.richfaces.model.TreeDataModel.doWalk(TreeDataModel.java:159)
       at org.richfaces.model.TreeDataModel.doWalk(TreeDataModel.java:159)
       at org.richfaces.model.TreeDataModel.walk(TreeDataModel.java:183)
       at org.richfaces.component.UITree.walk(UITree.java:422)
       at org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:655)
       at org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:601)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:239)
       at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:180)
       at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:127)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:188)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
       at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
       at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
       at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
       at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:385)
       at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:380)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:78)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:124)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:532)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.webcastellum.WebCastellumFilter.internalDoFilter(WebCastellumFilter.java:1800)
       at org.webcastellum.WebCastellumFilter.doFilter(WebCastellumFilter.java:1791)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
       at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
       at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
       at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
       at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
       at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      ...
      


      Though I suspect it might have to do something with my TreeNode-implementation:
      public class LazyIndexNode
       implements TreeNode<IndexEntity> {
      
       private static final long serialVersionUID = 1L;
      
       /**
       * ********* Fields ***********
       */
      
       private IndexEntity data;
      
       private TreeNode<IndexEntity> parent;
      
       private Map<Object, TreeNode<IndexEntity>> childrenMap;
      
       /**
       * ********* Setup ***********
       */
      
       public LazyIndexNode () {
       childrenMap = new LinkedHashMap<Object, TreeNode<IndexEntity>> (0);
       }
      
       public LazyIndexNode (final IndexEntity pData) {
       this ();
       data = pData;
       updateChildrenMap ();
       }
      
       /**
       * ********* Public Methods ***********
       */
      
       @Override
       public void addChild (final Object pIdentifier,
       final TreeNode<IndexEntity> pChild) {
      
       pChild.setParent (this);
       childrenMap.put (pIdentifier, pChild);
       }
      
       @Override
       public void removeChild (final Object pIdentifier) {
      
       TreeNode<IndexEntity> treeNode = childrenMap.remove (pIdentifier);
       if (treeNode != null) {
       treeNode.setParent (null);
       }
       }
      
       /**
       * ********* Private Methods ***********
       */
      
       protected final void updateChildrenMap () {
      
       if (childrenMap.isEmpty ()) {
       childrenMap = new LinkedHashMap<Object, TreeNode<IndexEntity>> (data.getChildCount ());
       for (IndexEntity child : data.getChildren ()) {
       addChild (child.getId (), new LazyIndexNode (child));
       }
       }
       }
      
       /**
       * ********* Advanced Get/Set ***********
       */
      
       @Override
       public boolean isLeaf () {
      
       return data.getChildCount () == 0;
       }
      
       @Override
       public TreeNode<IndexEntity> getParent () {
       return parent;
       }
      
       @Override
       public void setParent (final TreeNode<IndexEntity> pParent) {
       parent = pParent;
       }
      
       @Override
       public IndexEntity getData () {
      
       return data;
       }
      
       @Override
       public void setData (final IndexEntity pData) {
      
       data = pData;
       updateChildrenMap ();
       }
      
       @Override
       public Iterator<Map.Entry<Object, TreeNode<IndexEntity>>> getChildren () {
      
       return childrenMap.entrySet ().iterator ();
       }
      
       @Override
       public TreeNode<IndexEntity> getChild (final Object pIdentifier) {
      
       return childrenMap.get (pIdentifier);
       }
      }


      But I don't see any problematic code, do you?

      PS: using RichFaces 3.3.0.GA, Seam 2.1.1, Sun JSF 1.2

      Cheers,
      Stephan