1 2 Previous Next 23 Replies Latest reply on Nov 9, 2007 5:11 AM by viggo.navarsete

    JSF 1.2 + RichFaces in Portlet

    viggo.navarsete

      I've done some research:
      1. Downloaded source for ajax4jsf and richfaces and built it according to http://labs.jboss.com/wiki/HowToBuildRichFacesSnapshotManually
      2. Created a JSF portlet where I
      - bundled with the JSF Portletbridge from Sun, the richfaces-ui, richfaces-impl, richfaces-api. Also had to bundle the commons-digester and commons-beanutils for some reason.
      - My web.xml look like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>false</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
      
       <!-- RichFaces and ajax4jsf settings -->
       <context-param>
       <param-name>org.ajax4jsf.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
       <session-config>
       <session-timeout>
       30
       </session-timeout>
       </session-config>
       <welcome-file-list>
       <welcome-file>faces/welcomeJSF.jsp</welcome-file>
       </welcome-file-list>
       </web-app>
      


      -my portlet.xml looks like this:
      <?xml version="1.0" encoding="UTF-8"?>
      <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-ap
      p_1_0.xsd"
       version="1.0">
      
       <portlet>
       <description>Search</description>
       <portlet-name>Search</portlet-name>
       <display-name>Search</display-name>
       <portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class>
       <!-- This is a required parameter and must point to the first page of the JSF Application -->
       <init-param>
       <description>Portlet init view page</description>
       <name>com.sun.faces.portlet.INIT_VIEW</name>
       <value>/WEB-INF/jsp/Search.jsp</value>
       </init-param>
       <expiration-cache>0</expiration-cache>
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>VIEW</portlet-mode>
       </supports>
       <portlet-info>
       <title>Search</title>
       <short-title>Search</short-title>
       </portlet-info>
       </portlet>
      </portlet-app>
      
      
      - my jsp looks like this:
      <%@page contentType="text/html"%>
      <%@page pageEncoding="UTF-8"%>
      
      <%-- RichFaces taglibs --%>
      <%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
      
      <%-- JSF taglibs --%>
      <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
      <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
      
      <%-- portlet taglibs --%>
      <%@ page import="javax.portlet.*"%>
      <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
      
      
      <portlet:defineObjects />
      <%PortletPreferences prefs = renderRequest.getPreferences();%>
      
      <f:view>
       <rich:panel>
       <f:facet name="header">
       <h:outputText value="Olympus EVOLT E-500"/>
       </f:facet>
       </rich:panel>
      </f:view>
      



      When I create a portlet instance in JBoss Portal 2.6.0.GA (running on JBoss AS 4.2.0GA) and try to access the portlet I get this stacktrace:
      13:06:48,011 WARN [SkinFactoryImpl] Init parameter for a skin name changed to org.richfaces.SKIN
      13:06:54,827 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.ClassCastException: org.apache.catalina.core.ApplicationContextFacade
       at com.sun.faces.portlet.FacesContextFactoryImpl.getFacesContext(FacesContextFactoryImpl.jav
      a:64)
       at org.jboss.portal.faces.portlet.JSFMetaBridgeFacesContextFactoryImpl.getFacesContext(JSFMe
      taBridgeFacesContextFactoryImpl.java:47)
       at org.ajax4jsf.resource.InternetResourceService.getFacesContext(InternetResourceService.jav
      a:317)
       at org.ajax4jsf.resource.InternetResourceService.getResourceContext(InternetResourceService.
      java:251)
       at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.jav
      a:162)
       at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.jav
      a:144)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:259)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
      ava:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
      ava:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.ja
      va:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:
      156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja
      va:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)



      Anyone knows what is wrong?

        • 1. Re: JSF 1.2 + RichFaces in Portlet
          viggo.navarsete

          I think my issue can be related to this one:
          http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067355#4067355
          I will try to upgrade my JBoss Portal 2.6.0 to 2.6.1.GA and see what will happen.

          • 2. Re: JSF 1.2 + RichFaces in Portlet
            viggo.navarsete

            I still get the same stacktrace as prior to the upgrade. The way I upgraded the portal was to remove the jboss-portal.sar from my deploy directory, and replacing it with the new one. Could there be cached information which causes the same error as prior to the upgrade? Do I also have to upgrade the JBoss AS server from 4.2.0.GA to 4.2.1?

            • 3. Re: JSF 1.2 + RichFaces in Portlet
              viggo.navarsete

              Well, the stacktrace is actually not the same... Here's the new one:

              14:20:37,446 WARN [SkinFactoryImpl] Init parameter for a skin name changed to org.richfaces.SKIN
              14:20:40,342 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
              java.lang.ClassCastException: org.apache.catalina.core.ApplicationContextFacade
               at com.sun.faces.portlet.FacesContextFactoryImpl.getFacesContext(FacesContextFactoryImpl.java:64)
               at org.ajax4jsf.resource.InternetResourceService.getFacesContext(InternetResourceService.java:317)
               at org.ajax4jsf.resource.InternetResourceService.getResourceContext(InternetResourceService.java:251)
               at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:162)
               at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:144)
               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:259)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Thread.java:595)
              


              • 4. Re: JSF 1.2 + RichFaces in Portlet
                viggo.navarsete

                Update:
                I tried with a fresh installation of JBoss AS 4.2.1.GA and JBoss Portal 2.6.1.GA and deployed my "JSF RichFaces Portlet", and the stacktrace is still the same:

                08:37:37,523 WARN [SkinFactoryImpl] Init parameter for a skin name changed to org.richfaces.SKIN
                08:37:39,853 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                java.lang.ClassCastException: org.apache.catalina.core.ApplicationContextFacade
                 at com.sun.faces.portlet.FacesContextFactoryImpl.getFacesContext(FacesContextFactoryImpl.java:64)
                 at org.ajax4jsf.resource.InternetResourceService.getFacesContext(InternetResourceService.java:317)
                 at org.ajax4jsf.resource.InternetResourceService.getResourceContext(InternetResourceService.java:251)
                 at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:162)
                 at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:144)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:259)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                 at java.lang.Thread.run(Thread.java:595)


                ANYONE able to use RichFaces in a JSF portlet? Is it the JSF PortletBridge from Sun creating all these problems, or is it some ajax4jsf classes?

                • 5. Re: JSF 1.2 + RichFaces in Portlet
                  viggo.navarsete

                  I created an issue (http://jira.jboss.com/jira/browse/RF-572) and attached an example portlet you can look at to recreate this behaviour.

                  • 6. Re: JSF 1.2 + RichFaces in Portlet
                    leuwen2000

                    Hi

                    i have the same problem, did you find a solution to work around this issue ?

                    Thanks

                    • 7. Re: JSF 1.2 + RichFaces in Portlet
                      viggo.navarsete

                      Hi leuwen2000: The issue is still open, and moved from Richfaces 3.1.0 to Richfaces 3.2.0. Please vote for the solution, and ask questions about it on the forum. Perhaps it's taken into account earlier.
                      At the moment I'm just developing a JSF application, that i (hopefully) can use as a Portlet later (using a JSF Portlet bridge) if the issue is solved. If not, I'm FU**ED :(

                      • 8. Re: JSF 1.2 + RichFaces in Portlet
                        viggo.navarsete

                        Additional note: I've also tried to deploy the "JSF Richfaces portlet" in another container, like glassfish, with the same result. So it's Richfaces/Ajax4jsf problem, not a container problem. According to one of the Richfaces/ajax4jsf developers it's not an easy issue to fix, but I really hope they prioritize it soon.

                        • 9. Re: JSF 1.2 + RichFaces in Portlet
                          antoine_h

                          Hi,
                          I am also waiting for this small bug of class cast to be resolved, to start using RichFaces in JB Portal.
                          I voted on the Jira.
                          I will look if the last build have this resolved... may be it is, but not updated in the jira.

                          • 10. Re: JSF 1.2 + RichFaces in Portlet
                            suckerd

                            Mhh if you don't need JSF1.2 features you could use the following in your web.xml to configure JBOSS Portal Server 2.6.1GA

                            <!-- Special command to tell JBOSS 2.6.1 Portal and higher to use the application bundled JSF-libs (e.g. myfaces 1.1.5) and not the JSF-libs 1.2 from the container -->
                            <context-param> <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
                             <param-value>true</param-value>
                            </context-param>
                            


                            • 11. Re: JSF 1.2 + RichFaces in Portlet
                              suckerd

                              Mhh if you don't need JSF1.2 features you could use the following in your web.xml to configure JBOSS Portal Server 2.6.1GA

                              <!-- Special command to tell JBOSS 2.6.1 Portal and higher to use the application bundled JSF-libs (e.g. myfaces 1.1.5) and not the JSF-libs 1.2 from the container -->
                              <context-param> <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
                               <param-value>true</param-value>
                              </context-param>
                              


                              • 12. Re: JSF 1.2 + RichFaces in Portlet
                                viggo.navarsete

                                Thanks for input suckerd!
                                I'm not sure if I need any of the JSF 1.2 features, but since I'm setting up a new project/environment I would like to take advantage of the latest and greatest if possible.
                                Have you been able to use Richfaces with Myfaces since you suggest using MyFaces?

                                • 13. Re: JSF 1.2 + RichFaces in Portlet
                                  suckerd

                                  Oh and by the way you don't need the SUN-Bridge.
                                  the portlet extension of richfaces (portlet-3.1.0-SNAPSHOT.jar) comes with its own bridge (see svn under extensions portlet).

                                  Therefore the portlet.xml would look like:

                                  .....
                                  <portlet-class>
                                   org.ajax4jsf.portlet.AjaxFacesPortlet
                                  </portlet-class>
                                  .....


                                  and maybe you need to (re)define the ajaxContext request bean
                                  so the faces-config.xml would be like:
                                  
                                  <faces-config>
                                   <application>
                                  
                                   </application>
                                   <factory>
                                   <faces-context-factory>org.ajax4jsf.portlet.context.FacesContextFactoryImpl</faces-context-factory>
                                   </factory>
                                  
                                   <managed-bean>
                                   <managed-bean-name>ajaxContext</managed-bean-name>
                                   <managed-bean-class>org.ajax4jsf.portlet.PortletAjaxContext</managed-bean-class>
                                   <managed-bean-scope>request</managed-bean-scope>
                                   </managed-bean>
                                  
                                   <render-kit>
                                  
                                   <renderer>
                                   <description>
                                   override the viewroot
                                   </description>
                                   <component-family>javax.faces.ViewRoot</component-family>
                                   <renderer-type>javax.faces.ViewRoot</renderer-type>
                                   <renderer-class>org.ajax4jsf.portlet.renderkit.portlet.PortletAjaxViewRootRenderer</renderer-class>
                                   </renderer>
                                   </render-kit>
                                  
                                  </faces-config>
                                  
                                  


                                  • 14. Re: JSF 1.2 + RichFaces in Portlet
                                    viggo.navarsete

                                    Greeeeeeeeat!!
                                    I will try this tonight:)
                                    Too bad there's no complete example on how to use RichFaces in a portlet environment. Perhaps I have to write something if I am able to do this :)

                                    1 2 Previous Next