Chapter 19. Jakarta Server Faces configuration
The jsf
subsystem enables the installation of multiple Jakarta Server Faces implementations on the same JBoss EAP server instance. You can install a version of Sun Mojarra or Apache MyFaces that implements the Jakarta Server Faces 4.0 specification or later. The feature pack can only be used to install the Apache MyFaces implementation.
Only the Jakarta Server Faces implementation included with JBoss EAP is fully supported.
19.1. Installing a Jakarta Server Faces implementation
JBoss EAP supports provisioning a server with only the necessary features by using the JBoss EAP Installation Manager, which delivers these features as feature packs.
Prerequisites
- You have installed JBoss EAP.
Procedure
Create the
myfaces-manifest.yaml
file with the following content:schemaVersion: "1.0.0" name: "MyFaces manifest" id: "myfaces" streams: - groupId: "org.apache.myfaces.core" artifactId: "myfaces-api" version: "4.0.2" - groupId: "org.apache.myfaces.core" artifactId: "myfaces-impl" version: "4.0.2"
Add the MyFaces manifest by using the following command:
$JBOSS_HOME/bin/jboss-eap-installation-manager.sh channel add \ --channel-name=myfaces \ --manifest=myfaces-manifest.yaml \ --repositories=https://repo1.maven.org/maven2/
Deploy the MyFaces Maven manifest to your local Maven repository by using the following command:
mvn deploy:deploy-file -Dfile=myfaces-manifest.yaml \ -DgroupId=org.apache.myfaces.channel -DartifactId=myfaces \ -Dclassifier=manifest -Dpackaging=yaml -Dversion=4.0.2 \ -Durl=file://$HOME/.m2/repository
Provision a server using the MyFaces feature pack by using the following command:
$JBOSS_HOME/bin/jboss-eap-installation-manager.sh fp add \ --fpl=org.jboss.eap:eap-myfaces-feature-pack \ --layers=myfaces
- Start the server.
Verification
Use the following CLI command to verify that the new Jakarta Server Faces implementation has been installed successfully:
[standalone@localhost:9990 /] /subsystem=jsf:list-active-jsf-impls()
19.2. Changing the default Jakarta Server Faces implementation
The multi-Jakarta Server Faces feature includes the default-jsf-impl-slot
attribute in the jsf
subsystem, which enables you to change the default Jakarta Server Faces implementation.
Prerequisites
- You have the multiple Jakarta Server Faces implementations installed on the server.
Procedure
Use the
write-attribute
command to set the value of thedefault-jsf-impl-slot
attribute to one of the active Jakarta Server Faces implementations:/subsystem=jsf:write-attribute(name=default-jsf-impl-slot,value=JSF_IMPLEMENTATION)
Replace
JSF_IMPLEMENTATION
with the name of the Jakarta Server Faces implementation you want to set as default.Restart the JBoss EAP server for the change to take effect.
reload
Verification
Identify the available Jakarta Server Faces implementations by using the following command:
/subsystem=jsf:read-attribute(name=default-jsf-impl-slot)
- Expected output
{ "outcome" => "success", "result" => "myfaces" }
19.3. Jakarta Server Faces application configuration for non-default implementation
To configure a Jakarta Server Faces application to use a Jakarta Server Faces implementation other than the default, add the org.jboss.jbossfaces.JSF_CONFIG_NAME
context parameter to the web.xml
file. This parameter instructs the jsf
subsystem to apply the specified Jakarta Server Faces implementation when deploying the application.
For example, if you want to use MyFaces 4.0.0 in your application, include the following context parameter in the web.xml
file:
<context-param> <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name> <param-value>myfaces-4.0.0</param-value> </context-param>
If a Jakarta Server Faces application does not include this context parameter, the 'jsf' subsystem will use the default Jakarta Server Faces implementation.
19.4. Disallowing DOCTYPE declarations
You can configure the jsf
subsystem to disallow DOCTYPE
declarations in Jakarta Server Faces deployments. This setting improves security by preventing the use of external entities.
Prerequisites
-
You have management CLI access to configure the
jsf
subsystem.
Procedure
Disallow
DOCTYPE
declarations in all Jakarta Server Faces deployments by using the following command:/subsystem=jsf:write-attribute(name=disallow-doctype-decl, value=true)
Restart the JBoss EAP server for the changes to take effect:
reload
To allow
DOCTYPE
declarations for a specific Jakarta Server Faces deployment, add thecom.sun.faces.disallowDoctypeDecl
context parameter to the deployment’s web.xml file with the following configuration:<context-param> <param-name>com.sun.faces.disallowDoctypeDecl</param-name> <param-value>false</param-value> </context-param>