1 Reply Latest reply on Jul 27, 2011 11:59 PM by bradleydouglas

    RF 4 Tree in EAR

    bradleydouglas

      Hi all,

       

      I'm trying to get RF 4 working working in an app deployed as a .ear file.  In particular I'm running into problems when I try to show a taxonomy tree using RF tree.

       

      I've looked at the examples in the live demo and implemented the TreeNode on my TaxonomyNode entity:

       

      {code:java}public class TaxonomyNode extends EntityIdentified implements TreeNode {

      <snip>

      }{code}

      I'm passing a list of these to the the JSF page:

       

      {code:xml}<rich:tree id="tree" var="node" value="#{KingdomController.rootNodes}">

          <rich:treeNode >

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

          </rich:treeNode>

      </rich:tree>{code}

      When I try to hit the page I get the following error:

      2011-07-27 23:50:55,078 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/NaturalHistory].[Faces Servlet]] (http-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalAccessError: tried to access method org.richfaces.model.SwingTreeNodeImpl.setAllowUpdateParents(Z)V from class org.richfaces.model.SwingTreeNodeDataModelImpl

      at org.richfaces.model.SwingTreeNodeDataModelImpl.createFakeRootNode(SwingTreeNodeDataModelImpl.java:62) [:4.0.0.Final]

      at org.richfaces.model.SwingTreeNodeDataModelImpl.setWrappedData(SwingTreeNodeDataModelImpl.java:69) [:4.0.0.Final]

      at org.richfaces.component.AbstractTree.createExtendedDataModel(AbstractTree.java:491) [:4.0.0.Final]

      at org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:462) [:4.0.0.Final]

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

      at org.richfaces.renderkit.TreeEncoderFull.encode(TreeEncoderFull.java:45) [:4.0.0.Final]

      at org.richfaces.renderkit.TreeRendererBase.encodeTree(TreeRendererBase.java:92) [:4.0.0.Final]

      at org.richfaces.renderkit.html.TreeRenderer.encodeChildren(TreeRenderer.java:128) [:4.0.0.Final]

      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849) [:2.0.3-]

      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643) [:2.0.3-]

      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646) [:2.0.3-]

      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389) [:2.0.3-]

      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127) [:2.0.3-]

      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:269) [:2.0.3-]

      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:269) [:2.0.3-]

      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117) [:2.0.3-]

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

      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135) [:2.0.3-]

      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309) [: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(Thread.java:662) [:1.6.0_26]

       

      I've seen a lot of pages regarding class loaders and placement of jars in the WAR / EAR.  My current deployment layout is as follows:

      • richfaces-components-ui-4.0.0.Final.jar and richfaces-core-impl-4.0.0.Final.jar are in the WEB-INF/lib directory of the WAR file
      • The META-INF/MANIFEST.MF file contains

      {quote}Manifest-Version: 1.0

      Class-Path: \{quote}

      • richfaces-components-api-4.0.0.Final.jar and richfaces-core-api-4.0.0.Final.jar and the WAR are in the root directory of the EAR
      • appilcation.xml in the EAR pulls in the 2 jars in the EAR as follows:

       

      {code:xml}<module>

          <java>richfaces-components-api-4.0.0.Final.jar</java>

        </module>

       

        <module>

          <java>richfaces-core-api-4.0.0.Final.jar</java>

        </module>{code}

      Any insight into why this isn't working or how I should be deploying richfaces 4 best within an EAR would be greatly appreciated.

       

      Thanks,

      Brad

        • 1. Re: RF 4 Tree in EAR
          bradleydouglas

          Sorry to reply to my own post but I have some more info I hope will help.

           

          I orignally had all 4 richfaces jars in the WAR WEB-INF/lib directory as per the instructions in the dev guide (http://docs.jboss.org/richfaces/latest_4_0_X/Developer_Guide/en-US/html/chap-Developer_Guide-Getting_started_with_RichFaces.html#sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project_with_JBoss_Tools)

           

          However because I implemented TreeNode on me entity bean, I needed to move the api jars from the WAR to the EAR so that the EJB class loader could see TreeNode (as someone else ran into in RF 3: http://community.jboss.org/thread/160110.

           

          Now I believe that because SwingTreeNodeDataModelImpl (in components-ui jar) is in the WAR, and SwingTreeNodeImpl (in components-api) is in the EAR and since SwingTreeNodeImpl.setAllowUpdateParents is not public (it has no access modifier so is package-private by default) although both classes are declared in the org.richfaces.model package, because they are in differnet class loaders, the packages are not considered to be the same.  Hence, the java.lang.IllegalAccessError.

           

          I thought that if I got all the jars in the one class loader these problems would go away - which would explain why the getting started docs say to put them all in the WAR.  So I've tried pushing all the RF jars up into the EAR but then I get the class cast exception again:

          java.lang.ClassCastException: com.flutterer.taxonomy.entity.TaxonomyNode cannot be cast to javax.swing.tree.TreeNode

          at org.richfaces.model.SwingTreeNodeDataModelImpl.isLeaf(SwingTreeNodeDataModelImpl.java:87) [:4.0.0.Final]

              at org.richfaces.component.AbstractTree.isLeaf(AbstractTree.java:448) [:4.0.0.Final]

              at org.richfaces.component.TreeRange.shouldIterateChildren(TreeRange.java:56) [:4.0.0.Final]

              at org.richfaces.component.AbstractTree.walkModelChildren(AbstractTree.java:518) [:4.0.0.Final]

              at org.richfaces.component.AbstractTree.walkModelChildren(AbstractTree.java:536) [:4.0.0.Final]

              at org.richfaces.component.AbstractTree.walkModel(AbstractTree.java:510) [:4.0.0.Final]

              at org.richfaces.renderkit.TreeEncoderBase.encodeTree(TreeEncoderBase.java:96) [:4.0.0.Final]

              at org.richfaces.renderkit.TreeEncoderFull.encode(TreeEncoderFull.java:42) [:4.0.0.Final]

              at org.richfaces.renderkit.TreeRendererBase.encodeTree(TreeRendererBase.java:92) [:4.0.0.Final]

              at org.richfaces.renderkit.html.TreeRenderer.encodeChildren(TreeRenderer.java:128) [:4.0.0.Final]

              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849) [:2.0.3-]

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643) [:2.0.3-]

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646) [:2.0.3-]

              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389) [:2.0.3-]

              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127) [:2.0.3-]

              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:269) [:2.0.3-]

              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:269) [:2.0.3-]

              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117) [:2.0.3-]

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

              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135) [:2.0.3-]

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309) [: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(Thread.java:662) [:1.6.0_26]

           

          So can someone please let me know how I should have the libs layed out in my EAR to get a tree to work driven off data that extends TreeNode (I've tried lots of combiniations).  Also, it would be really useful if the docs considered more than just a simple WAR deployment.

           

          Altenatively if I'm way off on what the problem is, please let me know.  I've lost way to much time trying to get this to work.