Configuring jboss 7.1.1 with Mojarra 2.0.4 issues
nikh123123 May 22, 2012 9:46 AMI 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