migrating Java Server Faces 2.3 to Jakarta Faces 4.0

created onOctober 10, 2023
Work in Progress – I’m still in the transition from Java Server Faces 2.3 to Jakarta Faces 4.0 and will add here whatever I will encounter.

Jakarta Faces 3.0 didn’t bring any new features or changes, but was just a renaming of the javax.faces namespace to the jakarta.faces namespace. So I did the migration straight from Java Server Faces 2.3 to Jakarta Faces 4.0.

Java source code

Change all imports of javax.faces to jakarta.faces.

Facelets

renaming of the xmlbeans.jcp.org taglib URIs

The namespace of the taglib UIRs http://xmlns.jcp.org/jsf/* has been renamed to the URNs jakarta.faces.*. This is less confusing, because there were no XSDs behind the URLs anyway.

http://xmlns.jcp.org/jsp/jstl/* has been renamed to jakarta.tags.*.

Check that all Facelet templates and Facelets use the new URNs.

deprecated FacesConfig.Version

In JSF 2.3 Faces-specific CDI initialization was activated with

@FacesConfig( version = JSF_2_3 )

In Jakarta Faces 4.0, the parameter FacesConfig.Version is deprecated.

new feature extensionless mapping

There is a new feature called extensionless mapping which allows to omit the file suffix when requesting a Jakarta Faces page, i.e. instead of http://idoru/login.xhtml you can use http://idoru/login with extensionless mapping.

The context configuration parameter for extensionless mapping didn’t make it into the Jakarta Faces 4.0 Specification Documentation, so I am listing the syntax here:

<context-param> <param-name>jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING</param-name> <param-value>true</param-value> </context-param>

Maven coordinates for Primefaces

Since version 10.0.0, Primefaces comes in two kinds: one using javax.* dependencies, one using the jakarta.* dependencies. For Jakarta EE you need the classifier jakarta in the maven coordinates for the Primefaces dependency:

<dependency> <groupId>org.primefaces</groupId> <artifactId>primefaces</artifactId> <version>${primefaces.version}</version> <classifier>jakarta</classifier> </dependency>

Without the jakarta classifier, you’ll get javax.* kind. Using that in Jakarta EE will result in the java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener, which hit me when I fired up Payara Micro 6 with Primefaces 13 for the first time:

ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener

reference

github jakartaee/faces, Faces 4.0: rename xmlns.jcp.org taglib URIs #1553

github jakartaee/faces, Faces 4.0: Provide extensionless mapping #1508

github jakartaee/faces, Spec: Missing description of jakarta.faces.AUTOMATIC_EXTENSIONLESS_MAPPING parameter #1709

github jakartaee/faces, Faces 4.0: deprecate FacesConfig.Version #1594

github eclipse-ee4j/mojarra Deprecate @FacesConfig.Version #5017

Primefaces Documentation v10.0.0, Download, Download with Maven