1 2 Previous Next 21 Replies Latest reply on Jun 25, 2008 7:01 AM by subhajit sidhanta

    JSF Portlet tutorial out of date?

    Dean Des Rosiers Newbie

      I have been following the Portlet Tutorials that I downloaded with JBoss Portal 2.6.1 and have hit a snag. The HelloWorldJSFPortlet should extend a MyFaces portlet. JBoss AS 4.2.1 ships with Sun's RI, not MyFaces.

      I get this error:

      14:30:37,096 ERROR [[/helloworldjsfportlet]] Error configuring application listener of class org.apache.myfaces.webapp.StartupServletContextListener
      java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener

      Looking at the logs I see that Portal DOES use MyFaces, though. How do I bundle my portlet war to access MyFaces? Where do I deploy it?

      Thanks,
      Dean

      PS I am using the downloaded jboss-portal-2.6.1.GA. It bundled JBoss AS (4.2.1?). I'm not using a db apart from whatever Portal uses OOTB. SUsE 10.x.

        • 1. Re: JSF Portlet tutorial out of date?
          Andrew Chukwu Newbie

          Hi,

          Im a new-commer to to Jboss portal etc. There is a lot of info about. Your answer can be found on the Jboss wiki site: http://wiki.jboss.org/wiki/Wiki.jsp?page=Running2.6WithJBossAS4.2.xAndMyFaces

          JBoss 4.2.x ships with Sun JSF, replace as indicated in the wiki and it should work.

          • 2. Re: JSF Portlet tutorial out of date?
            Dean Des Rosiers Newbie

            Thanks, I'll try it. I DID search for an answer, but I guess not hard enough!

            Cheers,
            Dean

            • 3. Re: JSF Portlet tutorial out of date?
              Chris Laprun Master

               

              "andrewchukwu" wrote:
              Your answer can be found on the Jboss wiki site: http://wiki.jboss.org/wiki/Wiki.jsp?page=Running2.6WithJBossAS4.2.xAndMyFaces

              JBoss 4.2.x ships with Sun JSF, replace as indicated in the wiki and it should work.


              This is correct, but this would replace the JSF implementation at the application server level. You should be able to bundle MyFaces with your portlet without having to change the JSF implementation at the AS level. I will update the tutorial as needed.

              • 4. Re: JSF Portlet tutorial out of date?
                Dean Des Rosiers Newbie

                Does this require a sar as I see the portal-admin package does? Or can I make a war of it?

                How will I know when the tutorial has been updated?

                Thanks,
                Dean

                • 5. Re: JSF Portlet tutorial out of date?
                  Thomas Heute Master

                  There is already all the info here:
                  http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossFaces

                  (You don't need a sar, no service required)

                  • 6. Re: JSF Portlet tutorial out of date?
                    Dean Des Rosiers Newbie

                    Great. Thanks Thomas. I have read all the documentation cover to cover and am just starting to code.

                    I appreciate all your hard work. THANKS!

                    Dean

                    • 8. Re: JSF Portlet tutorial out of date?
                      Dean Des Rosiers Newbie

                      Hmmm. It's working for me.

                      • 9. Re: JSF Portlet tutorial out of date?
                        Dean Des Rosiers Newbie

                        1. Locate jboss-portal-2.6.1.GA/server/default/deploy/jboss-portal.sar/portal-admin.sar/portal-admin.war/WEB-INF/lib2/myfaces-impl.jar and jboss-portal-2.6.1.GA/server/default/deploy/jboss-portal.sar/portal-admin.sar/portal-admin.war/WEB-INF/lib2/myfaces-api.jar

                        2. Copy them to your tutorial app's WEB-INF/lib dir

                        3. Add the following to the web.xml in your tutorial app's WEB-INF:

                        <context-param>
                        <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
                        <param-value>true</param-value>
                        </context-param>

                        Cryptic? Yes. Proprietary? Yes. Does it work? Yes.

                        Hope this helps.

                        Dean

                        • 10. Re: JSF Portlet tutorial out of date?
                          JP Barbe Newbie

                          Hi,
                          I have the same error when I want to deploy my app on JBP 2.6.1.
                          My app uses Myfaces, Seam and portlet and works well under JBP 2.6.0 CR2 + JB 4.0.5 GA

                          I did exactly what you wrote, Dean, and now I have a new exception:

                          java.lang.IllegalArgumentException: Class org.jboss.seam.jsf.SeamApplicationFactory is no javax.faces.application.ApplicationFactory
                          


                          I'm sure that my EAR contains only on time the both myFaces jar (myfaces-impl.jar and myfaces-api.jar) in appli.war/WEB-INF/lib

                          Thanks for your help.
                          JP

                          • 11. Re: JSF Portlet tutorial out of date?
                            Dean Des Rosiers Newbie

                            OK, so SeamApplicationFactory is not an ApplicationFactory.

                            It sounds like MyFaces is unwilling to accept the SeamApplicationFactory for some reason.

                            I haven't started using Seam at all, so I could be way off, but perhaps the versions of Seam and MyFaces are not in agreement.

                            For this we need to know the exact version of MyFaces distributed with JBP 2.6.1 and the exact version of Seam you're using.

                            The other thing that could help is looking at the stack trace and finding out which MyFaces class doesn't like the Seam class.

                            Then... Read the MyFaces Source Code!

                            It is not as scary as it sounds and you can probably do it from a browser. I don't know what version control they're using.

                            Post the stack trace and I'll see what I can do. Maybe some JBoss person will take pity on us in the meantime.

                            Dean

                            • 12. Re: JSF Portlet tutorial out of date?
                              JP Barbe Newbie

                              Thanks for your help Dean.

                              The version of MyFaces distributed with JBP 2.6.1 is 1.1.1 and the version of Seam I use is 1.1.6 GA.

                              I tried to use MyFaces 1.1.4 which is distributed with JB 4.0.5. I replace the jars into jboss-portal-2.6.1.GA\server\default\deploy\jboss-portal.sar\portal-admin.sar\portal-admin.war\WEB-INF\lib2 and into my WAR, but I have the same result.

                              Here is the stackTrace:
                              java.lang.IllegalArgumentException: Class org.jboss.seam.jsf.SeamApplicationFactory is no javax.faces.application.ApplicationFactory
                              at javax.faces.FactoryFinder.newFactoryInstance(FactoryFinder.java:132)
                              at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:107)
                              at org.apache.myfaces.config.FacesConfigurator.configureApplication(FacesConfigurator.java:439)
                              at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:141)
                              at org.apache.myfaces.portlet.MyFacesGenericPortlet.initMyFaces(MyFacesGenericPortlet.java:184)
                              at org.apache.myfaces.portlet.MyFacesGenericPortlet.init(MyFacesGenericPortlet.java:110)
                              at javax.portlet.GenericPortlet.init(GenericPortlet.java:270)
                              at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.initPortlet(PortletContainerImpl.java:359)
                              at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:233)
                              at org.jboss.portal.portlet.impl.container.PortletApplicationContextImpl.startPortletApplication(PortletApplicationContextImpl.java:130)
                              at org.jboss.portal.portlet.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:153)
                              at org.jboss.portal.core.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:94)
                              at org.jboss.portal.server.deployment.jboss.DeploymentContext.start(DeploymentContext.java:99)
                              at org.jboss.portal.server.deployment.jboss.PortalDeploymentInfoContext.start(PortalDeploymentInfoContext.java:211)
                              at org.jboss.portal.server.deployment.jboss.ServerDeployer.start(ServerDeployer.java:217)
                              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                              at sun.reflect.GeneratedMethodAccessor212.invoke(Unknown Source)
                              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                              at java.lang.reflect.Method.invoke(Method.java:585)
                              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                              at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                              at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                              ...


                              What I don't understand is when I use JBP 2.6.0.CR2 with JB 4.0.5, MyFaces 1.1.4 and Seam 1.1.6 GA it works, but when I use the same versions of MyFaces and Seam on JBP 2.6.1 with JB 4.2.1, it tells me that SeamApplicationFactory is no ApplicationFactory !

                              I'll try to look what does MyFacesGenericPortlet while init.

                              Thanks.
                              JP

                              • 13. Re: JSF Portlet tutorial out of date?
                                Dean Des Rosiers Newbie

                                Here's the code from MyFaces...
                                http://svn.apache.org/repos/asf/myfaces/core/trunk/api/src/main/java/javax/faces/FactoryFinder.java

                                // check, if class is of expected interface type
                                if (!interfaceClass.isAssignableFrom(implClass))
                                {
                                throw new IllegalArgumentException("Class " + implClassName + " is no " + interfaceClass.getName());
                                }

                                Now let's find out why class.isAssignableFrom(class) returns false...
                                http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html

                                OK it is because it doesn't think that the SeamApplicationFactoryClass passed in is a subclass of the ApplicationFactory that was passed in.

                                You've been at this a couple days. This may sound nuts, but you could try to write a class that loads the SeamApplicationFactory and the MyFaces one and call isAssignableFrom. Put the code in a main method.

                                When you execute the class you'll also know exactly the classpath is set up because you will have set it up on the command line (-cp switch).

                                If it works in your little harness, then you know there is a weird classloader issue in JBoss. If it doesn't work in your harness, you'll also be able to swap out MyFaces jars easily and see which version works.

                                This may seem like a lot of work, but as I said, you've been at it two days already, and sometimes these exercises uncover... shall we say... "user errors." You know, the kind that you'll be embarrassed to tell me :)

                                Good luck. I'll be out the rest of the day.

                                • 14. Re: JSF Portlet tutorial out of date?
                                  JP Barbe Newbie

                                  Well, I did the main class with the test "isAssignableFrom" inside and it returns true.
                                  As you said, it probably means that there is a classLoader incompatibility with JBP 2.6.1 and my app.

                                  I did an other test:
                                  I tried to deploy my new EAR for JBP 2.6.1 (with myfaces-api.jar and myfaces-impl.jar in WEB-INF/lib and the parameter org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL (= true) in the web.xml) in JBP 2.6.0 CR2 + JB 4.0.5 GA.
                                  I have the same error whereas it works when I don't put the jars in the WAR.

                                  I think that my problem comes from the fact I had to put the myFaces jars in my application war to use Myfaces with JBP 2.6.1GA. But I don't know how to do differently...

                                  1 2 Previous Next