10 Replies Latest reply on Jun 1, 2012 1:26 AM by nikh123123

    Configuring jboss 7.1.1 with Mojarra 2.0.4 issues

    nikh123123

      I have a working webapp on Jboss 5.1.0 GA. Which uses Mojarra 2.0.4 jars. I'm in a process of migrating this on to Jboss 7.1.1. This version of jboss is shipped with 2.1.7. So I downgraded the Mojarra version by defining slots for 2.0.4 and referring to them as dependency in the `META-INF/jboss-deployment-structure.xml` along with other dependencies.

       

       

      jboss-deployment-structure.xml

       

       

       

       <?xml version="1.0" encoding="UTF-8"?>
          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
            <deployment>
                      <exclusions>
                    <module name="javax.faces.api" slot="main"/>
                    <module name="com.sun.jsf-impl" slot="main"/>
                    <module name="javax.faces.api" slot="1.2"/>
                    <module name="com.sun.jsf-impl" slot="1.2"/>          
                  </exclusions>
                  <dependencies>
                    <module name="org.hibernate.validator" export="true"/>
                    <module name="javax.validation.api" export="true"/>
                    <module name="com.google.gson" export="true"/>
                    <module name="org.codehaus.jettison" export="true"/>
                    <module name="org.jboss.resteasy.resteasy-jaxrs" export="true"/>
                    <module name="org.jboss.resteasy.resteasy-jackson-provider" export="true"/>
                    <module name="org.apache.log4j" export="true"/>
                    <module name="org.jboss.as.web" slot="main" export="true"/>
                    <module name="javax.faces.api" slot="2.0.4" export="true"/>
                    <module name="com.sun.jsf-impl" slot="2.0.4" export="true"/>       
                  </dependencies>
            </deployment>   
           </jboss-deployment-structure>
      

       

       

      This caused the following exception to be thrown at deployment

       

       

       

       12:51:18,761 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) Initializing Mojarra 2.0.4 (FCS b09) for context ''
          12:51:20,355 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) Unsanitized stacktrace from failed start...: javax.faces.FacesException: Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
      

       

      To which I referred to this link and modified my dependencies as follows

       

       

       

       <?xml version="1.0" encoding="UTF-8"?>
          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
            <deployment>
                                <exclusions>
                    <module name="javax.faces.api" slot="main"/>
                    <module name="com.sun.jsf-impl" slot="main"/>
                    <module name="javax.faces.api" slot="1.2"/>
                    <module name="com.sun.jsf-impl" slot="1.2"/>
                    <module name="org.jboss.as.web" slot="main" />
                  </exclusions>
                  <dependencies>
                    <module name="org.hibernate.validator" export="true"/>
                    <module name="javax.validation.api" export="true"/>
                    <module name="com.google.gson" export="true"/>
                    <module name="org.codehaus.jettison" export="true"/>
                    <module name="org.jboss.resteasy.resteasy-jaxrs" export="true"/>
                    <module name="org.jboss.resteasy.resteasy-jackson-provider" export="true"/>
                    <module name="org.apache.log4j" export="true"/>
                    <module name="org.jboss.as.web" slot="main" export="true"/>
                    <module name="javax.faces.api" slot="2.0.4" export="true"/>
                    <module name="com.sun.jsf-impl" slot="2.0.4" export="true"/>
                    <module name="org.jboss.as.web" slot="main">
                    <imports>
                                        <include path="/org/**" />
                                        <exclude path="/META-INF/**" />
                                </imports>
                                </module>
                  </dependencies>
            </deployment>   
           </jboss-deployment-structure>
      

       

      Which got rid of the error at deployment but introduced the following runtime exception

       

       

       

      12:59:19,434 ERROR [stderr] (http--0.0.0.0-8080-4) java.lang.IllegalArgumentException: null source
          12:59:19,435 ERROR [stderr] (http--0.0.0.0-8080-4)           at java.util.EventObject.<init>(EventObject.java:38)
          12:59:19,436 ERROR [stderr] (http--0.0.0.0-8080-4)           at javax.faces.event.SystemEvent.<init>(SystemEvent.java:71)
          12:59:19,444 ERROR [stderr] (http--0.0.0.0-8080-4)           at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:73)
      

       

      and

       

       

       

      12:59:19,489 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[Faces Servlet]] (http--0.0.0.0-8080-4) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
                    at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:431) [jsf-impl.jar:2.0.4-b09]
                    at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:72) [jsf-impl.jar:2.0.4-b09]
                    at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:559) [jsf-impl.jar:2.0.4-b09]
      

       

      I figured (by googling, of course) that the exception is often caused by three things

       

       

      1. Invalid/unclosed tags used in xhtml (a wrongly propagated exception)

      2. Session timeout (a wrongly propagated exception)

      3. Limit on no of POST parameters in Tomcat

       

       

      Unfortunately, first two were not the causes. I ran my erroneous xhtml pages through validators and found that markup was valid, neither was my session had expired. I also increased the `org.apache.tomcat.util.http.Parameters.MAX_COUNT` to 5000 in `standalone.xml` to address the third point. The error still persists.

       

       

      I also tried migrating to the default bundled Mojarra 2.7.1 version. That prevented the first runtime exception but the second one remained.

      The only peculiar thing about those pages causing this error is they have ajax calls in them.

      Funny enough, the application is working fine with Jboss 5.1.0 GA, so if my markup is erroneous, it would have given me a difficult time on 5.1.0 as well, which it didn't. So invalid markup is unlikely.

       

      UPDATE: Just found out that line at PartialViewContextImpl.java:431 shows that the ctx.getRenderKit() is evaluating to null. No idea why though

        • 1. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
          dahm

          Hi,

           

          we had  the same problem and solved it by simple replacing the JSF-Implementation of our server in

           

          .../modules/com/sun/jsf-impl

           

          where the module.xml looks like

           

          <module xmlns="urn:jboss:module:1.0" name="com.sun.jsf-impl">
              <dependencies>
                  <module name="javax.faces.api"/>
                  <module name="javaee.api"/>
                  <module name="javax.servlet.jstl.api"/>
                  <module name="org.apache.xerces" services="import"/>
                  <module name="org.apache.xalan" services="import"/>
              </dependencies>
              <resources>
                  <resource-root path="jsf-impl-2.0.6.jar"/>
                  <!-- Insert resources here -->
              </resources>
          </module>
          

           

          now.

           

          Cheers

             Markus

          • 2. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
            nikh123123

            Hi Markus!

            Thanks for sharing that! So do you mean that instead of defining slots for 2.0.4 jars, I should just replace the jars in the /modules/com/sun/jsf-impl/main and refer to them? Actually, I had tried it before defining slots. In short, I had hacked jboss to refer to 2.0.4 jars by changing the resource-root path in /modules/com/sun/jsf-impl/main and also in /modules/javax/faces/api/main. But that didn't help

            • 3. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
              dahm

              Hi,

               

              well the method you described solved the problem for us. We just replaced the implementation and it worked out of the box.

              I attached our replacement module, so you can see what we did. We have not configured anything special in the deployment descriptors.

               

              Cheers

                 Markus

              • 4. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                nikh123123

                Hi Markus!

                Thanks for the zip!

                Ok, please correct me if I'm wrong - You replaced the jsf-impl.jar and did not make any changes to /modules/javax/faces/api/main i.e. you did not replace the jsf-api.jar, right? Trying it that way now. Will get back asap!

                • 5. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                  nikh123123

                  Just tried it.. Didn't solve it I tried two approaches

                  1. Replacing only jsf-impl.jar and keeping jsf-api.jar intact
                  2. Replacing both

                   

                  Here's my jboss-deployment-structure.xml that I used with this configuration

                   

                  <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
                    <deployment>
                                        <exclusions>
                            <module name="javax.faces.api" slot="1.2"/>
                            <module name="com.sun.jsf-impl" slot="1.2"/>
                  </exclusions>
                  <dependencies>
                            <module name="javax.faces.api" export="true"/>
                            <module name="com.sun.jsf-impl" export="true"/>
                            <module name="org.hibernate.validator" export="true"/>
                            <module name="javax.validation.api" export="true"/>
                            <module name="com.google.gson" export="true"/>
                            <module name="com.google.guava" export="true"/>
                            <module name="org.codehaus.jettison" export="true"/>
                            <module name="org.jboss.resteasy.resteasy-jaxrs" export="true"/>
                            <module name="org.jboss.resteasy.resteasy-jackson-provider" export="true"/>
                            <module name="org.apache.log4j" export="true"/>
                            <module name="org.jboss.as.web" slot="main"/>          
                     </dependencies>
                    </deployment>   
                   </jboss-deployment-structure>
                  
                  • 6. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                    dahm

                    Hi,

                     

                    you should try without having a  jboss-deployment-structure.xml descriptor. If that's not possible try to omit everything depending on JSF concretely, i.e. the part with

                     

                     

                    <exclusions>
                              <module name="javax.faces.api" slot="1.2"/>
                              <module name="com.sun.jsf-impl" slot="1.2"/>
                    </exclusions>
                    ...
                    <module name="javax.faces.api" export="true"/>
                              <module name="com.sun.jsf-impl" export="true"/>
                    

                     

                    leaving everything to the defaults.

                     

                    We did have no jboss-deployment-structure.xml at all, so I' not sure...

                     

                    Cheers

                        Markus

                    • 7. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                      nikh123123

                      Ok I could strip it down to this much

                      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
                        <deployment>
                              <dependencies>
                                <module name="org.hibernate.validator" export="true"/>
                                <module name="javax.validation.api" export="true"/>
                                <module name="com.google.gson" export="true"/>
                                <module name="com.google.guava" export="true"/>
                                <module name="org.codehaus.jettison" export="true"/>
                                <module name="org.jboss.resteasy.resteasy-jaxrs" export="true"/>
                                <module name="org.jboss.resteasy.resteasy-jackson-provider" export="true"/>
                                <module name="org.apache.log4j" export="true"/>
                              </dependencies>
                        </deployment>   
                       </jboss-deployment-structure>
                      

                      But it didn't make any difference!

                      • 8. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                        dahm

                        Hi,

                         

                        my last guess is that there is something wrong with your web.xml or faces-config.xml.

                         

                        ours looked like this

                         

                        <web-app 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_3_0.xsd" version="3.0">
                        
                          <display-name>Foo</display-name>
                        
                          <context-param>
                            <param-name>javax.faces.PROJECT_STAGE</param-name>
                            <param-value>Production</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
                            <param-value>true</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
                            <param-value>true</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
                            <param-value>true</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>org.richfaces.skin</param-name>
                            <param-value>classic</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>org.richfaces.enableControlSkinning</param-name>
                            <param-value>true</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>org.richfaces.datatableUsesViewLocale</param-name>
                            <param-value>true</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>org.richfaces.enableControlSkinningClasses</param-name>
                            <param-value>false</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
                            <param-value>3145728</param-value>
                          </context-param>
                        
                          <context-param>
                            <param-name>org.richfaces.fileUpload.createTempFiles</param-name>
                            <param-value>false</param-value>
                          </context-param>
                        
                          <session-config>
                            <session-timeout>480</session-timeout>
                          </session-config>
                        
                          <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>*.seam</url-pattern>
                          </servlet-mapping>
                        
                          <mime-mapping>
                            <extension>ecss</extension>
                            <mime-type>text/css</mime-type>
                          </mime-mapping>
                        
                          <filter>
                            <filter-name>csvContentTypeFilter</filter-name>
                            <filter-class>com.foo.CsvContentTypeFilter</filter-class>
                          </filter>
                        
                          <filter-mapping>
                            <filter-name>csvContentTypeFilter</filter-name>
                            <url-pattern>/pages/export/*</url-pattern>
                          </filter-mapping>
                        
                          <security-constraint>
                            <web-resource-collection>
                              <web-resource-name>Protected Context</web-resource-name>
                              <url-pattern>/*</url-pattern>
                            </web-resource-collection>
                            <user-data-constraint>
                              <transport-guarantee>CONFIDENTIAL</transport-guarantee>
                            </user-data-constraint>
                          </security-constraint>
                        </web-app>
                        

                         

                        Cheers

                           Markus

                        • 9. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                          nikh123123

                          Thanks Markus!

                           

                          This is how ours looks like. Please let me know if you find any culprit there!

                          <?xml version="1.0" encoding="UTF-8"?>
                          <web-app id="WebApp_ID" 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">
                           <description>Foo application</description>
                           <display-name>Foo</display-name>
                           <context-param>
                            <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
                            <param-value>false</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.compressJavaScript</param-name>
                            <param-value>true</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.compressViewState</param-name>
                            <param-value>false</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.compressableMimeTypes</param-name>
                            <param-value>text/css,text/javascript,application/json</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.displayConfiguration</param-name>
                            <param-value>false</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.externalizeJavaScript</param-name>
                            <param-value>true</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.numberOfLogicalViews</param-name>
                            <param-value>10</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.numberOfViewsInSession</param-name>
                            <param-value>1</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.resourceUpdateCheckPeriod</param-name>
                            <param-value>-1</param-value>
                           </context-param>
                           <context-param>
                            <param-name>com.sun.faces.serializeServerState</param-name>
                            <param-value>false</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
                            <param-value>/WEB-INF/facelets/tags/mytaglib.xml</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
                            <param-value>-1</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
                            <param-value>true</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
                            <param-value>true</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
                            <param-value>true</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.faces.PROJECT_STAGE</param-name>
                            <param-value>Production</param-value>
                           </context-param>
                           <context-param>
                            <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
                            <param-value>resources.application</param-value>
                           </context-param>
                           <context-param>
                            <param-name>org.richfaces.resourceOptimization.enabled</param-name>
                            <param-value>true</param-value>
                           </context-param>
                           <filter>
                            <filter-name>Pretty Filter</filter-name>
                            <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
                           </filter>
                           <filter>
                            <display-name>SessionFilter</display-name>
                            <filter-name>SessionFilter</filter-name>
                            <filter-class>foo.web.SessionFilter</filter-class>
                            <init-param>
                             <param-name>redirectPath</param-name>
                             <param-value>loginRedirect.jsf</param-value>
                            </init-param>
                            <init-param>
                             <param-name>excludePaths</param-name>
                             <param-value>/login.jsf,/loginRedirect.jsf</param-value>
                            </init-param>
                           </filter>
                           <filter-mapping>
                            <filter-name>Pretty Filter</filter-name>
                            <url-pattern>/*</url-pattern>
                            <dispatcher>FORWARD</dispatcher>
                            <dispatcher>REQUEST</dispatcher>
                            <dispatcher>ERROR</dispatcher>
                           </filter-mapping>
                           <filter-mapping>
                            <filter-name>SessionFilter</filter-name>
                            <servlet-name>SchedulingHandle</servlet-name>
                            <dispatcher>REQUEST</dispatcher>
                            <dispatcher>FORWARD</dispatcher>
                            <dispatcher>INCLUDE</dispatcher>
                            <dispatcher>ERROR</dispatcher>
                           </filter-mapping>
                           <listener>
                            <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                           </listener>
                           <listener>
                            <listener-class>foo.web.listener.SessionTimeoutListener</listener-class>
                           </listener>
                           <servlet>
                            <servlet-name>Faces Servlet</servlet-name>
                            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                            <load-on-startup>1</load-on-startup>
                           </servlet>
                           <!-- //... Other servlet declarations and their mappings -->
                           <servlet>
                            <servlet-name>Resource Servlet</servlet-name>
                            <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
                            <load-on-startup>1</load-on-startup>
                           </servlet>
                           <servlet-mapping>
                            <servlet-name>Resource Servlet</servlet-name>
                            <url-pattern>/org.richfaces.resources/*</url-pattern>
                           </servlet-mapping>
                           <servlet-mapping>
                            <servlet-name>Faces Servlet</servlet-name>
                            <url-pattern>*.jsf</url-pattern>
                           </servlet-mapping> 
                           <session-config>
                            <session-timeout>30</session-timeout>
                           </session-config>
                           <mime-mapping>
                            <extension>ecss</extension>
                            <mime-type>text/css</mime-type>
                           </mime-mapping>
                           <welcome-file-list>
                            <welcome-file>index.html</welcome-file>
                            <welcome-file>index.htm</welcome-file>
                            <welcome-file>index.jsp</welcome-file>
                            <welcome-file>default.html</welcome-file>
                            <welcome-file>default.htm</welcome-file>
                            <welcome-file>default.jsp</welcome-file>
                           </welcome-file-list>
                           <error-page>
                            <exception-type>javax.faces.application.ViewExpiredException</exception-type>
                            <location>/loginRedirect.jsf</location>
                           </error-page>
                           <error-page>
                            <exception-type>java.lang.IllegalStateException</exception-type>
                            <location>/loginRedirect.jsf</location>
                           </error-page>
                           <error-page>
                            <error-code>404</error-code>
                            <location>/error_404.jsf</location>
                           </error-page>
                           <error-page>
                            <error-code>500</error-code>
                            <location>/error_500.jsf</location>
                           </error-page>
                          
                           <filter>
                                  <filter-name>Resteasy</filter-name>
                                  <filter-class>
                                      org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
                                  </filter-class>
                          </filter>
                          
                          <filter-mapping>
                           <filter-name>Resteasy</filter-name>
                           <url-pattern>/services/*</url-pattern>
                          </filter-mapping> 
                          <context-param>
                           <param-name>resteasy.servlet.mapping.prefix</param-name>
                           <param-value>/services</param-value>
                          </context-param>
                           <context-param>
                           <param-name>resteasy.scan.resources</param-name>
                           <param-value>true</param-value>
                          </context-param>
                          </web-app>
                          
                          

                           

                          • 10. Re: Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
                            nikh123123

                            Finally! It was not related to configuration at all! The issue was related to a bug in Mojarra 2.1.7 as reported here

                            The Solution is to give a name attribute to every pure html component included in <h:form>. The part that I could not understand that this bug seems to be related to Mojarra 2.1.7. And the jars I configured for my app were 2.0.4 version, yet the error was seen.

                            Thanks a lot everyone for the support!

                            P.S. : The error is also seen with Jboss 7.2.0 Alpha1