6 Replies Latest reply on May 7, 2009 9:20 PM by giorgio.grillini

    How to Configure ClassLoading in SEAM APP

      Hello


      I'm trying to deploy seam-gen (2.1.2.CR1) application with richfaces, unfortunately when I want to use bean, that operating on richfaces's class eg. UIExtendedDataTable, I need to copy richfaces-impl.jar & richfaces-ui.jar to project's "\lib" directory to run app (if not, I'm getting NoClassDefFoundError), but this evolve another problems, eg .with binding richfaces components&backing beans. After reading some post I assume that is classloader problem (seam-gen locates richfaces-impl.jar & richfaces-ui.jar in *.war\WEB-INF\lib\ directory and classloader for app-layer doesn't have access to them?) and I don't know how to set this properly.

      I will be great full for some advice, thank You.

      regards Chris

      (sorry for my English if any mistakes :))
        • 1. Re: How to Configure ClassLoading in SEAM APP
          giorgio.grillini

          That's a very good point! I've exactly the same problem as I've described here:My Link

          • 2. Re: How to Configure ClassLoading in SEAM APP
            niox.nikospara.yahoo.com

            Hello,


            I believe that business components (EJBs) should not be tied to view components (e.g. RichFaces classes). Personally, I put all web-related jars in WEB-INF/lib and access them through POJO SEAM components in the web-app. Then the POJO components call the business-tier components, when needed.


            That said, library placement in seam-gen'ed apps is controlled by the top-level files deployed-jars-ear.list and deployed-jars-war.list. The jars mentioned in deployed-jars-ear.list end up in the EAR/lib directory, and are accessible by all modules of the application. Those from deployed-jars-war.list end in WEB-INF/lib, and are only available to the web-app.


            Reorder the jars mentioned in these files to suit your needs.

            • 3. Re: How to Configure ClassLoading in SEAM APP

              Nikos Paraskevopoulos wrote on May 06, 2009 16:08:


              Hello,

              I believe that business components (EJBs) should not be tied to view components (e.g. RichFaces classes). Personally, I put all web-related jars in WEB-INF/lib and access them through POJO SEAM components in the web-app. Then the POJO components call the business-tier components, when needed.

              That said, library placement in seam-gen'ed apps is controlled by the top-level files deployed-jars-ear.list and deployed-jars-war.list. The jars mentioned in deployed-jars-ear.list end up in the EAR/lib directory, and are accessible by all modules of the application. Those from deployed-jars-war.list end in WEB-INF/lib, and are only available to the web-app.

              Reorder the jars mentioned in these files to suit your needs.


              I put bean's for richfaces in web-inf class folder and it's seems to be ok... I did it before I wrote earlier post, but I did not check this sufficiently closely .. I guess..
              Thanks for your advice :)

              • 4. Re: How to Configure ClassLoading in SEAM APP
                giorgio.grillini

                So, if I understand well, you (both Chris and Nikos) put a SEAM POJO using classes from richfaces in war's WEB-INF/classes and that did the trick right??
                I'm quite new to Seam, can you post your SEAM POJOs so I can give a look at your annotation??


                Thanks in advance to all!

                • 5. Re: How to Configure ClassLoading in SEAM APP
                  niox.nikospara.yahoo.com

                  Hi Giorgio,


                  What I said is:


                  1) I try to separate view-related functionality (like the RichFaces jars) from business related stuff (the EJBs). So I put all RichFaces jars in WEB-INF/lib. (In contrast, seam-gen puts some of these jars in global application scope, under EAR/lib.)


                  2) Therefore EJBs cannot access RichFaces classes (which is a good thing in my opinion). So if I want to access RichFaces-related stuff I use classes or SEAM POJO components in WEB-INF/classes (remembering to place an empty seam.properties there too).


                  All this is related to classloader setup, has nothing to do with annotations nor requires any special ones.


                  Additionally I try not to use JSF bindings of UI components to backing beans. So, unfortunately, I have no example to show you. But if you want to use JSF binding, you will only need a SEAM component (say "yourcomp") with the accessor methods (get/setProperty) for the JSF/RichFaces UI component, and the corresponding binding="#{yourcomp.property}" in the view.

                  • 6. Re: How to Configure ClassLoading in SEAM APP
                    giorgio.grillini

                    Thanks a lot Nikos, your information about putting seam.properties in WEB-INF/classes is the key of my little success!
                    I was trying and trying to put annotated POJO on the war but nothing happened. Now all works pretty well!
                    In case other people are going mad like me trying to get the selected node in a rich:tree with seam, jboss and richfaces, here is a little guide on how to do that:


                    1- Create an xhtml page like this:


                     <rich:panel  
                         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:s="http://jboss.com/products/seam/taglib"
                        xmlns:rich="http://richfaces.org/rich">
                           <h:form>
                             <rich:tree nodeSelectListener="#{fcTree.processSelection}"
                              ajaxSubmitSelection="true"  switchType="ajax"
                             value="#{fcTree.treeNode}" var="item" ajaxKeys="#{null}"/>
                                    
                           </h:form>
                    
                            
                     </rich:panel>



                    2- Create a bean (fcTree in the example) and deploy it in WEB-INF/classes along with a blank seam.properties. The bean is annotated like this:



                    ...
                    @Name("fcTree")
                    @Scope(ScopeType.SESSION)
                    public class Fctree {
                         
                        private TreeNode treeNode = null;  
                      
                        public void loadTree() {
                            
                            //put your code to load tree here
                       
                        }
                        
                    
                        public void processSelection(NodeSelectedEvent event) {
                    
                                  
                             HtmlTree tree = (HtmlTree) event.getComponent();
                             nodeTitle = (String) tree.getRowData();
                             
                             String key = tree.getRowKey().toString();
                    
                                //call the backend with key
                              
                        }
                        
                    
                        public TreeNode getTreeNode() {
                            
                            return treeNode;
                        }
                    
                    
                        public String getNodeTitle() {
                            return nodeTitle;
                        }
                    
                    }




                    that is the right way (in my opinion) to get richfaces components to work. The POJO isolate frontend from backend and you don't need to deal with libraries issue and get a lot of classnotfound and other weird errors!
                    Thanks to all, again!
                    Giorgio Grillini