Niks
Niks

Reputation: 4842

Configuring JBoss AS 7.1.1 with Mojarra 2.0.4 issues

I have a working webapp on JBoss AS 5.1.0 GA. Which uses Mojarra 2.0.4 jars. I'm in a process of migrating this on to JBoss AS 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 AS 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. Any pointers much appreciated!

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

UPDATE2: It turns out that the problem is seen only if I use pure html input components within the form i.e. <input type="text">, <select> etc. If I remove those from the <h:form> or I convert them into corresponding JSF tags, it works fine. Something is going terribly wrong somewhere. I'm not able to figure out excatly if this is caused by jboss, Mojarra or specifically my app. I tried it with a plain vanilla JSF app and it had no errors whether or not I use html input tags. So its the combination of my app and jboss 7.x that is causing this. Any ideas?

Upvotes: 2

Views: 4110

Answers (1)

Niks
Niks

Reputation: 4842

Finally! 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.

Upvotes: 2

Related Questions