3 Replies Latest reply on Mar 20, 2007 7:15 AM by Marcin M

    JBoss Seam + Facelets + Richfaces Tree error

    Ging Ming Chan Newbie

      I'm getting the following error once I tried to use the Richfaces Tree component:

      java.lang.ClassCastException: com.sun.facelets.StateWriter
       at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.endElement(HtmlResponseWriter.java:300)
       at org.richfaces.renderkit.html.TreeRenderer.doEncodeEnd(TreeRenderer.java:248)
       at org.richfaces.renderkit.html.TreeRenderer.doEncodeEnd(TreeRenderer.java:256)
       at org.ajax4jsf.framework.renderer.RendererBase.encodeEnd(RendererBase.java:114)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:827)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:803)
       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:571)
       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:248)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)


      My environment is Java 5, Tomcat 5.5.20, JSF 1.2_03, Facelets 1.1.11, JBoss Seam 1.2.0_patch1, JBoss Richfaces 3.0.0, Ajax4jsf 1.1.0

      I tried to use the Richfaces dataList and it works, so I guess my configuration for Richfaces is correct. May I know if anyone has successfully used the Tree and TreeNode of the latest Richfaces under JBoss Seam?

      Thanks for your help.

        • 1. Re: JBoss Seam + Facelets + Richfaces Tree error
          Marcin M Newbie

          I have different error but the component is the same aswell as configuration.

          from: http://jboss.com/index.html?module=bb&op=viewtopic&t=104440

          "kot.filemon" wrote:
          Anyone knows what am I doing wrong?

          I have one simple stateful bean which passes root node to tree component. When i try to display the page i'm redirected to seam debug page and get following exception

          20:01:59,011 ERROR [STDERR] Mar 19, 2007 8:01:59 PM com.sun.facelets.FaceletViewHandler handleRenderException
          SEVERE: Error Rendering View[/tree.xhtml]
          java.lang.ClassCastException: richtest.tree.TreeNodeExample
           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:524)
           at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:244)
           at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
           at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:573)
           at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
           at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
           at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
           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.BaseFilter.doFilter(BaseFilter.java:234)
           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.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
           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.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.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.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:595)
          


          I checked what is AbstractTreeDataModel.setWrappedData responsilble for:

           public final void setWrappedData(Object data) {
           wrappedData = (TreeNode) data;
           }
          


          so, I have put a breakpoint there and checked what Object data appear to be. As expected it was my implementation of TreeNode.

          package richtest.tree;
          
          import java.util.HashMap;
          import java.util.Iterator;
          import java.util.Map;
          
          import org.richfaces.component.TreeNode;
          
          public class TreeNodeExample implements TreeNode {
          
           /**
           *
           */
           private static final long serialVersionUID = 1L;
          
           private Map<Object, TreeNode> childs;
          
           private TreeNode parent;
          
           private String name;
          
           public TreeNodeExample() {
           childs = new HashMap<Object, TreeNode>();
          
           }
          
           public TreeNodeExample(String name) {
           this();
           this.name = name;
          
           }
          
           public TreeNodeExample(String name, TreeNode parent) {
           this(name);
           setParent(parent);
          
           }
          
           public void addChild(Object id, TreeNode child) {
           getChilds().put(id, child);
          
           }
          
           public int getChildsSize() {
           return getChilds().size();
           }
          
           private Map<Object, TreeNode> getChilds() {
           return this.childs;
           }
          
           public TreeNode getChild(Object id) {
           return (TreeNode) getChilds().get(id);
           }
          
           public Iterator getChildren() {
           return getChilds().entrySet().iterator();
           }
          
           public Object getData() {
          
           return this;
           }
          
           public TreeNode getParent() {
           return parent;
           }
          
           public boolean isLeaf() {
           return getChilds().isEmpty();
           }
          
           public void removeChild(Object id) {
           TreeNode tmp = getChild(id);
           tmp.setParent(null);
           getChilds().remove(id);
          
           }
          
           public void setData(Object arg0) {
           // not used
          
           }
          
           public void setParent(TreeNode parent) {
           if (parent != null) {
           TreeNodeExample ex = (TreeNodeExample) parent;
           parent.addChild(ex.getChildsSize(), this);
           }
           this.parent = parent;
          
           }
          
           public String getName() {
           return name;
           }
          
           public void setName(String name) {
           this.name = name;
           }
          
           public String toString() {
           return name;
           }
          
          }
          


          my page:
          
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <div xmlns="http://www.w3.org/1999/xhtml"
           xmlns:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.ajax4jsf.org/rich"
           xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
          
          
           <ui:composition template="/template.xhtml">
          
           <ui:define name="body">
           <f:view>
           <h:form>
           <div>
          
           <rich:tree width="300" height="150"
           value="#{treeExample.data}" var="item" nodeFace="test">
           <rich:treeNode type="test">
           <h:outputText value="#{item.name}" />
           </rich:treeNode>
           </rich:tree>
          
           </div>
          
           </h:form>
           </f:view>
           </ui:define>
           </ui:composition>
          
          </div>
          


          the template
          
          <?xml version="1.0" encoding="utf-8"?>
          <!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:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:rich="http://richfaces.ajax4jsf.org/rich">
           <head>
           <meta http-equiv="Content-Type"
           content="text/html; charset=iso-8859-1" />
           <meta http-equiv="expires" content="0" />
           <title>Test</title>
          
           <style type="text/css">
          /* a lot of classes */
          </style>
          
           </head>
          
           <body>
          
           <h:form>
           <rich:toolBar itemSeparator="line">
           <rich:toolBarGroup itemSeparator="grid">
          
           <h:commandLink value="simple" action="/slider.seam" />
           <h:commandLink value="tree" action="/tree.seam" />
           <h:commandLink value="table" action="/table.seam" />
           </rich:toolBarGroup>
          
           </rich:toolBar>
           </h:form>
           <ui:insert name="body">
           TOPNAV
           </ui:insert>
           </body>
          </html>
          
          


          and the stateful bean

          package richtest.tree;
          
          import javax.ejb.Remove;
          import javax.ejb.Stateful;
          
          import org.jboss.seam.annotations.Destroy;
          import org.jboss.seam.annotations.Name;
          
          @Stateful
          @Name("treeExample")
          public class TreeManager implements ITreeManager {
          
           private TreeNodeExample root;
          
           @Remove
           @Destroy
           public void destroy() {
          
           }
          
           public Object getData() {
           if (root == null)
           init();
          
           return root;
           }
          
           private void init() {
          
           this.root = new TreeNodeExample("root");
           for (int i = 0; i < 6; i++) {
           TreeNodeExample item = new TreeNodeExample("item" + i, root);
           }
          
          
           }
          }
          
          
          


          with it's inteface

          package richtest.tree;
          
          import javax.ejb.Local;
          
          
          @Local
          public interface ITreeManager {
          
           public void destroy();
          
          
          
           public Object getData();
          }
          
          


          please, help ;)


          • 2. Re: JBoss Seam + Facelets + Richfaces Tree error
            Dustin Norlander Apprentice

            Richfaces suffers from the same classloading problems as icefaces. Have you tried setting the usejbossslassloader=true (search the forums for instructions)?

            -Dustin

            • 3. Re: JBoss Seam + Facelets + Richfaces Tree error
              Marcin M Newbie

               

              "dustismo" wrote:
              Richfaces suffers from the same classloading problems as icefaces. Have you tried setting the usejbossslassloader=true (search the forums for instructions)?

              -Dustin


              thanks, it helped.

              I have edited the server/default/deploy/jbossweb-tomcat55.sar/META-INF/jboss-service.xml

              and changed Java2ClassLoadingCompliance and UseJBossWebLoader from false to true, and suddenly, the error disappeared.