Version 1.2.2
Migrate the current project to Jakarta Faces $ARGUMENTS (if no argument, ask the developer for the target version).
Step 1: Detect Current Version
Determine the current Faces version from:
pom.xmlorbuild.gradledependencies (look forjavax.faces,jakarta.faces,jsf-api,myfaces-api).faces-config.xmlversion attribute.- XML namespaces in XHTML files (
java.sun.com= JSF 1.0+,xmlns.jcp.org= JSF 2.2+,jakarta.faces= Faces 4.0+). - Package imports in Java files (
javax.faces= JSF 1.x/2.x vsjakarta.faces= Faces 3.0+).
Also determine the runtime type:
- Full EE server (WildFly, GlassFish, TomEE, Payara, WebSphere, Liberty, etc.): Faces, CDI, BV, EJB, JPA, JAX-RS, etc. are all provided by the runtime; the project should depend on the Java EE / Jakarta EE API artifact with
<scope>provided</scope>, not on standalone implementations. - Barebones servlet container (Tomcat, Jetty, Undertow, etc.) or framework (Spring Boot): Tomcat only provides Servlet, JSP, EL, WebSocket, and JASIC; everything else (Faces, CDI, BV, JSTL, etc.) must be installed/bundled separately with the application.
When updating dependencies in migration steps, update the appropriate artifact:
- On a full EE server: update the EE API version and ensure the target server version supports the target Faces version.
- Java EE 8 (JSF 2.3):
javax:javaee-web-api:8.0with<scope>provided</scope> - Jakarta EE 9 (Faces 3.0):
jakarta.platform:jakarta.jakartaee-web-api:9.0.0with<scope>provided</scope> - Jakarta EE 10 (Faces 4.0):
jakarta.platform:jakarta.jakartaee-web-api:10.0.0with<scope>provided</scope> - Jakarta EE 11 (Faces 4.1):
jakarta.platform:jakarta.jakartaee-web-api:11.0.0with<scope>provided</scope>
- Java EE 8 (JSF 2.3):
- On a barebones servlet container: update the standalone Faces implementation version directly (e.g.
org.glassfish:jakarta.facesfor Mojarra,org.apache.myfaces.core:myfaces-implfor MyFaces); do NOT usejavaee-apiorjakarta.jakartaee-apias a substitute because it will allow compiling against APIs that the servlet container doesn't actually provide.
Report the detected version and runtime type, and confirm with the developer before proceeding.
Step 2: Determine Migration Path
Based on source → target version, apply the relevant steps below. Multiple steps may apply for multi-version jumps (e.g. JSF 2.0 → Faces 4.1 requires all intermediate steps).
Migration Steps
JSF 1.x → JSF 2.0+ (major rewrite)
This is a significant migration; confirm scope with developer before proceeding.
- Replace JSP files with Facelets (XHTML).
- Replace
<f:view>,<f:subview>with Facelets templating (<ui:composition>,<ui:define>). - Replace
<managed-bean>entries infaces-config.xmlwith@ManagedBean+ scope annotations (will be migrated to@Namedin later step). - Replace
<navigation-rule>entries infaces-config.xmlwith return values from action methods or?faces-redirect=true. - Replace
javax.faces.webapp.FacesServletURL pattern/faces/*or*.facesor*.jsfwith*.xhtml.
JSF 2.x → JSF 2.3 (incremental)
- Update
pom.xmlto JSF 2.3 dependency. - Replace
@ManagedBean+@javax.faces.bean.*Scopedwith@Named+@javax.enterprise.context.*Scoped. @ViewScoped: replacejavax.faces.bean.ViewScopedwithjavax.faces.view.ViewScoped.- Ensure
beans.xmlexists inWEB-INF/withbean-discovery-mode="all"or"annotated". - Replace
@javax.faces.bean.ManagedPropertyon managed beans with@Inject. - Replace
@javax.faces.bean.ManagedPropertyon unmanaged variables with@javax.faces.annotation.ManagedProperty. - FacesServlet: ensure URL pattern is
*.xhtml; remove legacy*.jsf,*.faces,/faces/*mappings. - Update
faces-config.xmlversion to2.3.<faces-config xmlns="https://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://xmlns.jcp.org/xml/ns/javaee https://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd" version="2.3" > - Update
*.taglib.xmlversion to2.3.<facelet-taglib xmlns="https://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://xmlns.jcp.org/xml/ns/javaee https://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_3.xsd" version="2.3" > - Update XML namespaces from
java.sun.comtoxmlns.jcp.org(if on JSF 2.2+). - Use HTML5 doctype
<!DOCTYPE html>(if on JSF 2.2+). - Review for new 2.3 features to adopt: https://arjan-tijms.omnifaces.org/p/jsf-23.html
JSF 2.3 → Faces 3.0 (Jakarta EE 9, namespace rename)
This is purely a package rename; no behavioral changes.
- Update
pom.xmlto Jakarta Faces 3.0 dependency. - Rename ALL
javax.faces.*imports tojakarta.faces.*in Java files. - Rename ALL
javax.servlet.*tojakarta.servlet.*. - Rename ALL
javax.inject.*tojakarta.inject.*. - Rename ALL
javax.enterprise.*tojakarta.enterprise.*. - Rename ALL
javax.annotation.*tojakarta.annotation.*. - Rename ALL
javax.validation.*tojakarta.validation.*. - Rename ALL
javax.persistence.*tojakarta.persistence.*(if JPA is used). - Rename ALL
javax.ejb.*tojakarta.ejb.*(if EJB is used). - Rename ALL
javax.ws.rs.*tojakarta.ws.rs.*(if JAX-RS is used). - Update
web.xmlcontext param names fromjavax.faces.*tojakarta.faces.*. - FacesServlet: ensure URL pattern is
*.xhtml; remove legacy*.jsf,*.faces,/faces/*mappings. - Update
faces-config.xmlnamespace and version to3.0.<faces-config xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_3_0.xsd" version="3.0" > - Update
*.taglib.xmlnamespace and version to3.0.<facelet-taglib xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facelettaglibrary_3_0.xsd" version="3.0" > - NOTE: XHTML namespaces stay the same (
xmlns.jcp.org) in Faces 3.0; they only change in 4.0. - Use HTML5 doctype
<!DOCTYPE html>(if not already).
Faces 3.0 → Faces 4.0+ (Jakarta EE 10+, spec overhaul)
- Update
pom.xmlto Jakarta Faces 4.0 dependency. - Update XHTML namespaces from
xmlns.jcp.orgtojakarta.facesURNs:http://xmlns.jcp.org/jsf/html→jakarta.faces.htmlhttp://xmlns.jcp.org/jsf/core→jakarta.faces.corehttp://xmlns.jcp.org/jsf/facelets→jakarta.faces.faceletshttp://xmlns.jcp.org/jsf/composite→jakarta.faces.compositehttp://xmlns.jcp.org/jsf/passthrough→jakarta.faces.passthroughhttp://xmlns.jcp.org/jsf→jakarta.faceshttp://xmlns.jcp.org/jsp/jstl/core→jakarta.tags.core
- Remove
xmlns="http://www.w3.org/1999/xhtml"from XHTML files; since Faces 4.0 it is always implied. - Remove any remaining
@ManagedBeanusage (removed in Faces 4.0); replace with@Named+ CDI scope. - Remove any
javax.faces.bean.*imports (package removed entirely). - FacesServlet: ensure URL pattern is
*.xhtml; remove legacy*.jsf,*.faces,/faces/*mappings. - Update
faces-config.xmlversion to4.0.<faces-config xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_4_0.xsd" version="4.0" > - Update
*.taglib.xmlversion to4.0.<facelet-taglib xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst