6 Replies Latest reply on Jun 8, 2010 10:58 AM by barbara b

    Richfaces adviseNodeOpened ClassNotFoundException

    barbara b Newbie

      Hello

      I have a problem when I add

       

      public Boolean adviseNodeOpened(UITree tree) {
              return Boolean.TRUE;
          }

       

      to my MenuTreeBean.java

       

      The problem is the import of org.richfaces.component.UITree. This import can't be found when I don't add richfaces-ui.jar into the ear context. So I added richfaces-ui.jar to the ear context, but then I got the error java.lang.ClassNotFoundException: org.ajax4jsf.component.UIDataAdaptor. So I also added richfaces-impl.jar to the ear-context, but then I get the error

       

      Exception during request processing:

      Caused by javax.servlet.ServletException with message: "Servlet execution  threw an exception"
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      I read something about putting UseJBossWebLoader on true in jboss-serice.xml, but  is not in the jboss-serice.xml I have.
      Is there someone who had the same problem and solved it?
      Thanks
      barbara
        • 1. Re: Richfaces adviseNodeOpened ClassNotFoundException
          Ilya Shaikovsky Master

          seems you trying to use UI components classes inside EJB beans. It's not good design. Use controller classes in web application.

          1 of 1 people found this helpful
          • 2. Re: Richfaces adviseNodeOpened ClassNotFoundException
            barbara b Newbie

            Thanks you Ilya for your quick response.

             

            When I remove UITree out of the method

             

            public Boolean adviseNodeOpened() {
                    return Boolean.TRUE;
                }

             

            I get the error

             

            /layout/navigatie.xhtml @6,118 adviseNodeOpened="#{menuTree.adviseNodeOpened}":  Method not found: Proxy to  jboss.j2ee:ear=ccinc-ear.ear,jar=ccinc-ejb.jar,name=MenuTreeBean,service=EJB3  implementing [interface  vo.cjsm.ccinc.util.MenuTree].adviseNodeOpened(org.richfaces.component.UITree)

             

             

            And when I try <rich:tree switchType="client" selectedClass="navigatieTree" adviseNodeOpened="true"> I get java.lang.String cannot be cast to java.lang.Boolean

             

            What I want to do is to keep the tree open, because when I click on a link in the tree, the tree is collapsing when I go to a different page. Do you know another way to keep de tree expanded?

             

            Thanks

            barbara

            • 3. Re: Richfaces adviseNodeOpened ClassNotFoundException
              Ilya Shaikovsky Master

              When I remove UITree out of the method

               

              public Boolean adviseNodeOpened() {
                      return Boolean.TRUE;
                  }

              I meant not to remove UITree from signature - advisor expectes methodExpression of predefined signature so it will not works. I mean move out the advisor (which is actually some kind of UI controller) - to webapp module.

              And when I try <rich:tree switchType="client" selectedClass="navigatieTree" adviseNodeOpened="true"> I getjava.lang.String cannot be cast to java.lang.Boolean

              could also try to use adviseNodeOpened="#{true}"

              1 of 1 people found this helpful
              • 4. Re: Richfaces adviseNodeOpened ClassNotFoundException
                barbara b Newbie

                One step further but not yet there...

                 

                I created a TreeAdvisorBean in the webapp module

                 

                import javax.ejb.Remove;
                import javax.ejb.Stateful;

                 

                import org.jboss.seam.ScopeType;
                import org.jboss.seam.annotations.AutoCreate;
                import org.jboss.seam.annotations.Destroy;
                import org.jboss.seam.annotations.Name;
                import org.jboss.seam.annotations.Scope;
                import org.richfaces.component.UITree;
                import org.richfaces.component.state.TreeStateAdvisor;

                 

                @Stateful
                @Name("treeAdvisor")
                @Scope(ScopeType.SESSION)
                @AutoCreate
                public class TreeAdvisorBean implements TreeStateAdvisor {
                   
                    public Boolean adviseNodeOpened(UITree tree) {
                        return Boolean.TRUE;
                    }

                 

                    public Boolean adviseNodeSelected(UITree tree) {
                        return null;
                    }
                   
                    @Remove
                    @Destroy
                    public void destroy() {
                        // TODO Auto-generated method stub   
                    }
                }

                 

                and in the page:

                 

                <rich:tree switchType="client" selectedClass="navigatieTree" adviseNodeOpened="#{treeAdvisor.adviseNodeOpened}">

                 

                No more problem with the imports, but I get the error

                 

                /layout/navigatie.xhtml @6,121  adviseNodeOpened="#{treeAdvisor.adviseNodeOpened}": Target Unreachable,  identifier 'treeAdvisor' resolved to null

                 

                although I added @AutoCreate ... Has it something to do with the fact that the bean is in the webmodule?

                • 5. Re: Richfaces adviseNodeOpened ClassNotFoundException
                  Ilya Shaikovsky Master

                  check in server log during server starting - there should be Seam log entries related to components instantiations. there should be treeAdvisor.

                  • 6. Re: Richfaces adviseNodeOpened ClassNotFoundException
                    barbara b Newbie

                    Great! I added seam.properties in war/src, I removed @Stateful and I made the bean Serializable and it works! Thanks for the advice, Ilya!!