Configuring Liberty for JavaServer Faces 2.2

You can configure Liberty for the JavaServer Faces (JSF) 2.2 feature, which provides full support for the JSF 2.2 specification.

About this task

The Liberty JSF implementation is based on the MyFaces open source implementation. To configure a Liberty server to run an application that is enabled for JSF 2.2, you must set the <jsf-2.2> feature.

Procedure

Update the server.xml file to add the <jsf-2.2> feature.
For example:
<featureManager>
	<feature>jsf-2.2</feature>
</featureManager>
Important:
Consider the following points when you use JavaServer Faces 2.2:
  • JSF 2.2 feature does not implicitly load the bean validation feature like the JSF 2.0 feature does. When you migrate your application from JSF 2.0 to JSF 2.2, and your application uses bean validation, you must also enable the beanValidation-1.1 feature.
  • The JSF 2.2 feature requires the servlet-3.1, jsp-2.3, and el-3.0 features. When the JSF 2.2 feature is enabled in the server.xml file, each of these features is also enabled.
  • You cannot run the JSF 2.2 feature with Java EE 6 features; for example, servlet-3.0, jsp-2.2 and cdi-1.0.
  • You can choose between the JSF 2.0 and JSF 2.2 feature implementations for each server instance, but you must consider any behavior changes. If the required behavior is contained only in the JSF 2.2 feature, then you must use the JSF 2.2 feature. If an existing application would be adversely affected by behavior changes in the JSF 2.2 feature, then use the JSF 2.0 feature to preserve the existing behavior for that application.
  • It is not possible to use both the JSF 2.0 and JSF 2.2 features in the same Liberty server. If both features are configured, it produces an error:
    CWWKF0033E: The singleton features jsf-2.0 and jsf-2.2 cannot be loaded at the same time.  The configured features jsf-2.0 and jsf-2.2 include one or more features that cause the conflict. Your configuration is not supported; update server.xml to remove incompatible features.
  • JSF 2.2 is compatible with earlier releases, such as JSF 2.1 and JSF 2.0; however, consider the following exceptions:
    • An error in previous versions of the JSF specification caused exceptions to be swallowed that now are propagated to the exception handler. Read Backward Compatibility with Previous Versions in the overview section of the JSF 2.2 specification.
    • Changes made to the specification for Composite Component Attribute ELResolver and Composite Computer Metadata. Read Backward Compatibility with Previous Versions in the overview section of the JSF 2.2 specification.

Results

The JSF 2.2 feature is enabled and loads in the Liberty server at run time.

What to do next

To use the FlowBuilder API to create Flows with FlowBuilder annotations, it is required that the relevant CDI producer method is declared within a managed bean or a session bean class. To ensure that the class is managed correctly by CDI, define the producer method class as a managed bean (by giving it a scope), or set CDI bean-discovery-mode to all. You can set the CDI bean-discovery-mode to all in the beans.xml file in your web archive:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" 
	bean-discovery-mode="all">
</beans>