7 Replies Latest reply on Feb 2, 2011 12:20 PM by ssilvert

    WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?

    alexmcchessers

      Hi there.  I wonder if anyone can help with this problem.

       

      I am developing an application using MyFaces 2.0, which may be deployed on JBoss, Tomcat, or some other app server.  Our beans are within jar files and we'd like to use annotation discovery to locate them.  Because we need to bundle MyFaces with the application, within web.xml we have org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL set to "true".

       

      Unfortunately, none of our beans are being picked up.  The .jars do contain their own "faces-config.xml" within META-INF, and metadata-complete is set to "false", so it SHOULD be scanning them.  Also, if I deploy to Tomcat 6, it finds them successfully.  At first I thought that this could be a problem with MyFaces, so I temporarily switched it to Mojarra, and started to see ZipException errors in the log.

       

      This pointed me towards the following defect from an earlier Milestone build: https://issues.jboss.org/browse/JBAS-8024

       

      That defect appears to have been fixed by implementing a new annotation scanner.

       

      Now, if I remove the MyFaces jars from my application, set JSF_CONFIG_NAME to "MyFaces-2.0", and set WAR_BUNDLES_JSF_IMPL to "false", things start working correctly in JBoss.  So it appears to me that, for annotation discovery to work correctly in JBoss 6, your app has to use a built-in JSF implementation.  I would be ok with that, but if I include myfaces jars in the webapp to allow them to be picked up when deployed on Tomcat, it seems to always use those instead, and fails, regardless of what WAR_BUNDLES_JSF_IMPL is set to.  I'd rather not have to produce multiple deployments with different jars in web-inf/lib if I can help it.  Is this a defect?  Is 6.0 ignoring WAR_BUNDLES_JSF_IMPL and always looking for a bundled implementation, only falling back on the built-in version if it's not found?  Or am I missing something?  Can I force my bundled JSF implementation to use the JBoss annotation scanner?

       

      Any help would be greatly appreciated.

       

      Alex

        • 1. Re: WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
          ssilvert

          When you use WAR_BUNDLES_JSF_IMPL you are completely on your own to hook up things like annotation scanning.  So you need to add the things to your WAR that JBoss otherwise would add automatically.  Namely, you need to put a copy of jboss-faces.jar in your WEB-INF/lib.  Then you need to put this in web.xml or a web-fragment.xml:

             <listener>
               <listener-class>org.jboss.web.jsf.integration.config.JBossMyFaces20ServletContextListener</listener-class>
             </listener>
          

           

          That should do it, but I've never actually tried it that way.  Please let me know how it turns out.

           

          Stan

          • 2. WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
            alexmcchessers

            Hi Stan.  Thanks for the suggestion, but unfortunately it hasn't helped.  At first the webapp was failing to deploy, since WAR_BUNDLES_JSF_IMPL was set to true, and JBoss wasn't exposing its MyFaces implementation and the context listener to it.  Setting it to false got it to see the listener and deploy the webapp, but it's still not finding my beans.

             

            Alex

            • 3. WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
              ssilvert

              It sounds like you didn't put jboss-faces.jar into your WEB-INF/lib.  If WAR_BUNDLES_JSF_IMPL is set to true then jboss-faces.jar won't be in the classpath.  So you have to get it into the classpath yourself by manually putting a copy in your deployment.

               

              Stan

              • 4. WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
                alexmcchessers

                I've manually added jboss-faces.jar, and the webapp correctly deploys with WAR_BUNDLES_JSF_IMPL set to true, but still my beans are not being picked up.

                 

                In any case, it's looking as though I'm going to have to have separate webapps for Tomcat and JBoss, unless I give up on having it auto-discover beans.

                • 5. WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
                  ssilvert

                  What version of MyFaces are you using?  AS6 is using 2.0.1 right now.  The specific version might make a difference.

                   

                  Stan

                  • 6. WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
                    alexmcchessers

                    Ah-ha!  I was using MyFaces 2.0.2, but dropping back to 2.0.1 seems to have fixed it.  In fact, it seems that I no longer have to include JBossMyFaces20ServletContextListener nor the jboss-myfaces jar.  Presumably the correct annotation scanner is picked up automatically providing the correct version of MyFaces is provided.

                     

                    Thanks for your help.

                    • 7. Re: WAR_BUNDLES_JSF_IMPL ignored on JBoss 6.0?
                      ssilvert

                      Thanks for the info.  It will help me going forward.

                       

                      I think you'll still need JBossMyFaces20ServletContextListener if you want bean validation to work properly.  It might also be needed for JSP-based apps.

                       

                      Stan