Wednesday, January 29, 2014

How to run JSF 1.2 Application in JBoss AS 7.1.1 Final

In one of my earlier post I have described how can we upgrade the JSF version. Yesterday, I was being asked that how can we downgrade the version. So I created a sample project to do this. It is true that many of you have applications developed in older version of Java Server Faces, JSF 1.2 and if you want to run those application in JBoss AS 7.1.1 maybe these post will help you.
JBoss AS 7.1.1 comes with the backward compatibility of JSF 1.2. The required jars can be found in the following path:
  • jsf-impl: <path_to_your_server>/modules/com/sun/jsf-impl/1.2
  • jsf-api: <path_to_your_server>/modules/javax/faces/api/1.2
But you need to inform the server that your application is a JSF 1.2 application. To do this you need to:
  • Declare your webapp version to Servlet 2.5. 
  • Define a context param which would tell JBoss to use JSF 1.2.
Here is my webapp declaration:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> 
</web-app>
And the context param is:
<context-param>
 <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
 <param-value>Mojarra-1.2</param-value>
</context-param>
You don't need to place JSF 1.2 jars in your WEB-INF/lib. When you run the application if you see:
12:15:34,896 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-9) Initializing Mojarra (1.2_15.jbossorg-1-20111019-SNAPSHOT) for context '/your-app'
in your console you are good to go.
Cheers.
Download.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.