Creating a custom JSF deployer in JBoss AS 6.X

Submitted by Jochus on Sun, 30/12/2012 - 18:47 | Posted in: Java

JBoss AS 6.X gets shipped with Mojarra 2.0.3 (b5), but I wanted to do some testing with Mojarra 2.0.9. To be able to use this JSF implementation, you need to create a custom JSF deployer:

~ $ cd /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer $ mkdir Mojarra-2.0.9
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer $ cd Mojarra-2.0.9/
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/Mojarra-2.0.9 $ mkdir META-INF jsf-libs

In the META-INF folder, create the following file: web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="<a href="http://java.sun.com/xml/ns/javaee"&#10">http://java.sun.com/xml/ns/javaee"&#10</a>;   xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance"&#10">http://www.w3.org/2001/XMLSchema-instance"&#10</a>;   xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&#10">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&#10</a>;   version="2.5">
   <!-- ======================== Introduction ============================== -->
   <!-- This document defines default values for the Mojarra-2.0 JSF config  -->
   <!--                                                                      -->
   <!-- WARNING:  Do not configure application-specific resources here!      -->
   <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
 
   <!-- =========== Common Context Params ================================== -->
 
   <!-- Regular expression to determine if two different URLs actually point -->
   <!-- to the same jar file.  This keeps faces-config files from being      -->
   <!-- read twice.                                                          -->
   <context-param>
     <param-name>com.sun.faces.duplicateJARPattern</param-name>
     <param-value>^tmp\d+(\S*\.jar)</param-value>
   </context-param>
 
   <!-- JBossInjectionProvider provides resource injection for managed beans. -->
   <!-- See JSF 1.2 spec section 5.4 for details.                             -->
   <context-param>
     <param-name>com.sun.faces.injectionProvider</param-name>
     <param-value>org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider</param-value>
   </context-param>
 
   <!-- ================== Common filter Configuration ==================== -->
 
 
   <!-- ================== Common Listener Configuration ==================== -->
   <!-- Configures JSF 2.0 -->
   <listener>
     <listener-class>org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener</listener-class>
   </listener>
 
</web-app>

In jsf-libs:

  • Copy the file jboss-faces.jar from the 2.0.3 folder
  • Download the JSF libraries from: http://javaserverfaces.java.net/download.html
  • This should result in something as:
    /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/Mojarra-2.0.9/jsf-libs $ ls -al
    total 4952
    drwxr-xr-x  5 jochen  staff      170 Nov  7 16:58 .
    drwxr-xr-x  4 jochen  staff      136 Nov  7 16:44 ..
    -rw-r--r--@ 1 jochen  staff     6148 Nov  7 16:58 .DS_Store
    -rw-r--r--@ 1 jochen  staff  2502592 Nov  7 16:45 javax.faces-2.0.9.jar
    -rw-rw-r--@ 1 jochen  staff    21804 Aug 16  2011 jboss-faces.jar



Open the file: /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/META-INF/jsf-integration-deployer-jboss-beans.xml:

  • Extend the property jsfConfigurations:
        <property name="jsfConfigurations">
          <map keyClass="java.lang.String" valueClass="java.lang.String">
            ...
            <entry>
              <key>Mojarra-2.0.9</key>
              <value>${jboss.server.home.url}deployers/jsf.deployer/Mojarra-2.0.9</value>
            </entry>
            ...
          </map>
        </property>
  • Add the following bean:
      ...
      <bean name="JSFUrlIntegrationDeployer-209" class="org.jboss.jsf.deployer.JSFUrlIntegrationDeployer">
        <property name="JSFConfigName">
          <value>Mojarra-2.0.9</value>
        </property>
        <property name="JSFImplManagementDeployer">
          <inject bean="JSFImplManagementDeployer"/>
        </property>
      </bean>
      ...



Finally, to let your web application use the correct JSF deployer, make a reference in your WEB-INF/web.xml of your application (using the context-param: org.jboss.jbossfaces.JSF_CONFIG_NAME) :

	<context-param>
		<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
		<param-value>Mojarra-2.0.9</param-value>
	</context-param>

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.