11 Replies Latest reply on Mar 27, 2008 4:57 PM by Sergey Smirnov

    RichFaces with JSF RI 1.1

    sy62k Newbie

      Hi,
      I have a web application thats running on JBoss 4.0.5. I wanted to integrate RichFaces libraries and added them to WEB-INF/lib and the build path in Eclipse and did a build and deployed. This is before modifying web.xml to include the richfaces filters. When I try to login on my app it throws the following exception:

      java.lang.ClassCastException: java.lang.Boolean
       javax.faces.component.html.HtmlGraphicImage.restoreState(HtmlGraphicImage.java:665)
       javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1007)
       javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1019)
       org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:246)
       com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:228)
       org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
       org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
       com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:157)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
       org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
       com.company.miscellaneous.SecurityFilter.doFilter(SecurityFilter.java:35)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      


      I added the following entries to the deployment descriptor:
      <context-param>
      <param-name>org.richfaces.SKIN</param-name>
      <param-value>blueSky</param-value>
      </context-param>
      <filter>
      <display-name>RichFaces Filter</display-name>
      <filter-name>richfaces</filter-name>
      <filter-class>org.ajax4jsf.Filter</filter-class>
      </filter>
      <filter-mapping>
      <filter-name>richfaces</filter-name>
      <servlet-name>Faces Servlet</servlet-name>
      <dispatcher>REQUEST</dispatcher>
      <dispatcher>FORWARD</dispatcher>
      <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>
      


      It's throwing the same exception.

      Any help is appreciated,
      Thanks,
      -H


        • 1. Re: RichFaces with JSF RI 1.1
          Sergey Smirnov Master

          it is a jboss cache problem, most likely. Try to clean up tmp/work

          • 2. Re: RichFaces with JSF RI 1.1
            sy62k Newbie

            Sergey,

            I cleared the folders tmp/work with no luck.
            Any other ideas please!

            Thanks for your help,
            -H

            • 3. Re: RichFaces with JSF RI 1.1
              Sergey Smirnov Master

              No other ideas. Should work.

              P.S. I hope you do not try 3.2.0

              • 4. Re: RichFaces with JSF RI 1.1
                sy62k Newbie

                I tried it with 3.1.4, 3.1.2SP1 and I see the same behavior.

                The web.xml looks like:

                <?xml version="1.0" encoding="UTF-8"?>
                
                <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
                
                 <listener>
                 <listener-class>
                 com.sun.faces.config.ConfigureListener
                 </listener-class>
                 </listener>
                
                 <context-param>
                 <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                 <param-value>client</param-value>
                 </context-param>
                
                 <context-param>
                 <param-name>javax.faces.application.CONFIG_FILES</param-name>
                 <param-value>/WEB-INF/faces-config.xml</param-value>
                 </context-param>
                
                <context-param>
                <param-name>org.richfaces.SKIN</param-name>
                <param-value>blueSky</param-value>
                </context-param>
                <filter>
                <display-name>RichFaces Filter</display-name>
                <filter-name>richfaces</filter-name>
                <filter-class>org.ajax4jsf.Filter</filter-class>
                </filter>
                <filter-mapping>
                <filter-name>richfaces</filter-name>
                <servlet-name>Faces Servlet</servlet-name>
                <dispatcher>REQUEST</dispatcher>
                <dispatcher>FORWARD</dispatcher>
                <dispatcher>INCLUDE</dispatcher>
                </filter-mapping>
                 <!-- Faces Servlet -->
                 <servlet>
                 <servlet-name>Faces Servlet</servlet-name>
                 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
                 </servlet>
                
                 <!-- Faces Servlet Mapping -->
                 <servlet-mapping>
                 <servlet-name>Faces Servlet</servlet-name>
                 <url-pattern>/faces/*</url-pattern>
                 </servlet-mapping>
                
                <filter>
                 <filter-name>ExtensionsFilter</filter-name>
                 <filter-class>
                 org.apache.myfaces.component.html.util.ExtensionsFilter
                 </filter-class>
                 <init-param>
                 <param-name>uploadMaxFileSize</param-name>
                 <param-value>2m</param-value>
                 </init-param>
                 <init-param>
                 <param-name>uploadThresholdSize</param-name>
                 <param-value>100k</param-value>
                 </init-param>
                 </filter>
                
                 <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <servlet-name>Faces Servlet</servlet-name>
                 </filter-mapping>
                
                 <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
                 </filter-mapping>
                
                 And some other application related configuration
                


                Thanks for your help,
                -H

                • 5. Re: RichFaces with JSF RI 1.1
                  Sergey Smirnov Master

                  according to you stack trace, you have both Sun's JSF RI and shipped with JBoss 4.0.5 MyFaces JSF. Most likely, the problem you face relates to conflict between those two implementations running simultaneously.
                  You have nothing wrong with RichFaces from the configuration point of view.

                  • 6. Re: RichFaces with JSF RI 1.1
                    sy62k Newbie

                    Thats what I too thought. I removed the myfaces component completely and any references to it and tried it again.

                    The exception is the same even though the stacktrace has changed a bit this time:

                    java.lang.ClassCastException: java.util.HashMap
                     at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1109)
                     at javax.faces.component.UIOutput.restoreState(UIOutput.java:179)
                     at javax.faces.component.html.HtmlOutputLink.restoreState(HtmlOutputLink.java:838)
                     at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1007)
                     at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1019)
                     at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:246)
                     at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:228)
                     at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
                     at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
                     at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:157)
                     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
                     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
                     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
                     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                     at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                     at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                     at java.lang.Thread.run(Unknown Source)


                    • 7. Re: RichFaces with JSF RI 1.1
                      Sergey Smirnov Master

                      do you have other JSF applications deployed at the same jboss ?

                      • 8. Re: RichFaces with JSF RI 1.1
                        sy62k Newbie

                        Yeah. They work fine. Even this application works ok when I remove the richfaces libraries from WEB-INF/lib

                        • 9. Re: RichFaces with JSF RI 1.1
                          Sergey Smirnov Master

                          Refer to the Jboss doc how to solve problem with classloader.

                          • 10. Re: RichFaces with JSF RI 1.1
                            sy62k Newbie

                            Thanks for the pointer. I went through the wiki pages about class loading and added the following as recommended

                            <class-loading>
                             <loader-repository java2ClassLoadingCompliance="false">
                             com.mycompany:archive=myapp
                             <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                             </loader-repository>
                             </class-loading>
                            


                            It shows another form of error:
                            15:07:25,633 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                            java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
                             at java.lang.ClassLoader.defineClass1(Native Method)
                             at java.lang.ClassLoader.defineClass(Unknown Source)
                             at java.security.SecureClassLoader.defineClass(Unknown Source)
                             at java.net.URLClassLoader.defineClass(Unknown Source)
                             at java.net.URLClassLoader.access$100(Unknown Source)
                             at java.net.URLClassLoader$1.run(Unknown Source)
                             at java.security.AccessController.doPrivileged(Native Method)
                             at java.net.URLClassLoader.findClass(Unknown Source)
                             at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:672)
                             at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:652)
                             at java.lang.ClassLoader.loadClass(Unknown Source)
                             at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:190)
                             at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
                             at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
                             at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:517)
                             at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
                             at java.lang.ClassLoader.loadClass(Unknown Source)
                             at java.lang.ClassLoader.loadClassInternal(Unknown Source)
                             at org.ajax4jsf.application.AjaxStateManager.<init>(AjaxStateManager.java:90)
                             at org.ajax4jsf.event.InitPhaseListener.beforePhase(InitPhaseListener.java:87)
                             at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:192)
                             at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
                             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                             at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                             at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                             at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                             at java.lang.Thread.run(Unknown Source)
                            
                            


                            Am I doing something wrong?

                            Thanks,
                            -H

                            • 11. Re: RichFaces with JSF RI 1.1
                              Sergey Smirnov Master

                               

                              "sy62k" wrote:

                              15:07:25,633 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                              java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
                              


                              Am I doing something wrong?

                              Thanks,
                              -H


                              You need to have a apache commons-collections.jar version 3.2 . This class is from there.
                              So, two possible problems:
                              1) wrong version of the commons-collections
                              2) still a problem with classpath