3 Replies Latest reply on Apr 18, 2007 12:55 PM by Nicola Ben

    rich:tree component don't see what my class implements TreeN

    Eugene Batogov Newbie

      Hello!
      My configuration:
      JSF: 1.2._04
      JBoss SEAM: 1.2.1.GA
      RichFaces: 3.0.1-20070402
      JVM: Sun RI JVM 6.0
      OS: Fedora Linux

      I am trying use rich:tree component, but afoul with next trouble.
      I have class which implements TreeNode interface:
      ------------------------------------------------
      @Name("treeMenu")
      public class TreeMenu implements TreeNode, Serializable {

      private static final long serialVersionUID = 6980908422325671888L;

      private Map sections = null;

      private long nextId = 0;

      public long getNextId() {
      System.out.println("call method getNextId()");
      return this.nextId++;
      }

      private Map getSections() {
      System.out.println("call method getSections()");
      if (this.sections == null) {
      this.sections = new HashMap();
      this.initData();
      }
      return this.sections;
      }

      public void addSection(final Section section) {
      System.out.println("call method addSerction()");
      this.addChild(Long.toString(section.getId()), section);
      section.setParent(this);
      }

      public void addChild(final Object identifier, final TreeNode child) {
      System.out.println("call method addChild()");
      this.getSections().put(identifier, child);
      }

      public TreeNode getChild(final Object id) {
      System.out.println("call method getChild()");
      return (TreeNode) this.getSections().get(id);
      }

      public Iterator getChildren() {
      System.out.println("call method getChildren()");
      return this.getSections().entrySet().iterator();
      }

      public Object getData() {
      System.out.println("call method getData()");
      return this;
      }

      public TreeNode getParent() {
      System.out.println("call method getParent()");
      return null;
      }

      public boolean isLeaf() {
      System.out.println("call method isLeaf()");
      return this.getSections().isEmpty();
      }

      public void removeChild(final Object id) {
      System.out.println("call method removeChild()");
      this.getSections().remove(id);
      }

      public void setData(final Object date) {
      }

      public void setParent(final TreeNode parent) {
      }

      public String getType() {
      System.out.println("call method getType()");
      return "treeMenu";
      }

      private void initData() {
      .....
      }

      }
      ------------------------------------------------

      But, when I try to adress at my.xhml page JBoss throw nest stack with errors:
      -------------------------------------------------
      14:47:31,940 ERROR [STDERR] 02.04.2007 14:47:31
      com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/index.xhtml]
      java.lang.ClassCastException:
      ru.cti.oss.iptv.manager.jsf.TreeMenu$$EnhancerByCGLIB$$a41f6355 cannot
      be cast to org.richfaces.component.TreeNode
      at
      org.richfaces.component.AbstractTreeDataModel.setWrappedData(AbstractTreeDataModel.java:63)
      at org.richfaces.component.UITree.createDataModel(UITree.java:477)
      at
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:464)
      at
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:280)
      at
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:265)
      at
      org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:395)
      at
      org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:299)
      at
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
      at
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
      at
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
      at
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
      at
      com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:578)
      at
      org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      at
      org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
      at
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
      at
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at
      org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
      at
      org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
      at
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at
      org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:619)

      -------------------------------------------------
      Why this occurred?
      Eclipse tell me, that I implements interface TreeNode properly !
      Why occured : ClassCastException ?
      Help me , please .

        • 1. Re: rich:tree component don't see what my class implements T
          Evgeny Morozov Newbie

          I have the same on the example. It seems you are too... So, on my page I see nothing - on the source page there is a tree, but without data. And my Library entity is not invoked. How did you do that your tree trying to work and generate exception.
          In my case I just want to see at least an exception =)

          • 2. Re: rich:tree component don't see what my class implements T
            Dustin Norlander Apprentice

            This looks like a classloading problem. try setting

            usejbossclassloader=true


            (search the forum for instructions)

            -Hope that helps
            Dustin

            • 3. Re: rich:tree component don't see what my class implements T
              Nicola Ben Novice

              Hi!
              I have the same problem with RichFaces' TreeNode.

              As suggested in previous posts, I set to TRUE the options in jboss-service.xml:

              <attribute name="UseJBossWebLoader">true</attribute>


              and

              <attribute name="Java2ClassLoadingCompliance">true</attribute>


              But going to the page containing the tree I get the following:

              org.ajax4jsf.framework.resource.ResourceNotFoundException: Resource not registered : org.richfaces.renderkit.html.images.TreeLineCollapsedImage


              My EAR contains:

              ajax4jsf-1.1.1-SNAPSHOT.jar
              antlr-2.7.6.jar
              antlr-3.0ea8.jar
              commons-jci-core-1.0-406301.jar
              commons-jci-janino-2.4.3.jar
              commons-lang-2.1.jar
              drools-compiler-3.0.5.jar
              drools-core-3.0.5.jar
              el-api.jar
              el-ri.jar
              janino-2.4.3.jar
              jboss-seam.jar
              jbpm-3.1.2.jar
              jsf-facelets.jar
              oscache-2.3.2.jar
              richfaces-3.0.1-SNAPSHOT.jar
              stringtemplate-2.3b6.jar



              My WAR contains (in WEB-INF/lib) :

              ajax4jsf-1.1.1-SNAPSHOT.jar
              commons-fileupload.jar
              jboss-seam-debug.jar
              jboss-seam-mail.jar
              jboss-seam-ui.jar
              jsf-facelets.jar
              oscache-2.3.2.jar
              richfaces-3.0.1-SNAPSHOT.jar
              selectitems.jar
              selectitems-ui.jar



              In my JAR I have:

              commons-io-1.3.jar
              richfaces-3.0.1-SNAPSHOT.jar


              What is missing in my configuration, please?
              How to solve the exception:
              org.ajax4jsf.framework.resource.ResourceNotFoundException: Resource not registered : org.richfaces.renderkit.html.images.TreeLineCollapsedImage