Migrate to Jakarta EE 10
Jakarta EE 10 is the enterprise Java baseline that modern application servers, Spring, and a long tail of frameworks now build on. It carries forward the jakarta.* namespace introduced in Jakarta EE 9 – the rename of every javax.* enterprise package – and layers on new API versions such as Servlet 6.0, Persistence 3.1, and CDI 4.0, while removing methods and classes that had been deprecated for years.
For a codebase still on the javax.* APIs, that is a sprawling change: every enterprise import, every annotation attribute, every deployment descriptor, and every API dependency has to move in lockstep, and the deprecated-method removals are easy to miss until something fails at runtime.
The JakartaEE10 recipe applies these changes automatically: it migrates the javax.* namespace to jakarta.*, updates the Jakarta EE API and platform dependencies to their EE 10 versions, replaces deprecated APIs, and updates the XML descriptors and third-party libraries that need to move alongside them.
In this guide, we will show you how to run this recipe on the Moderne Platform or with the Moderne CLI.
Prerequisites
Before running this recipe, make sure:
- Your codebase currently uses the
javax.*enterprise APIs (Java EE or Jakarta EE 8) or an earlier Jakarta EE 9 release.JakartaEE10includes the Jakarta EE 9 namespace migration transitively, so thejavaxtojakartarename and the EE 10 updates are applied in a single run – you do not need to migrate to Jakarta EE 9 first. - Your build environment uses Java 11 or later. Jakarta EE 10 sets its baseline at Java SE 11 and also supports Java SE 17. If you are still on Java 8, run Migrate to Java 17 first and verify everything still builds.
What this recipe does
JakartaEE10 is a composite recipe that bundles many smaller transformations. Some of the most visible changes this recipe makes to your code include:
- Migrate the
javax.*namespace tojakarta.*– the foundational rename covering Servlet, Persistence, Validation, CDI, JMS, and JAX-RS APIs, along with thexmlnsdeclarations in deployment descriptors likeweb.xml,beans.xml, andejb-jar.xml. - Update Jakarta EE API dependencies to their EE 10 versions – bumps API artifacts such as
jakarta.servlet-apito 6.0.x,jakarta.persistence-apito 3.1.x, andjakarta.validation-apito 3.0.x. - Replace deprecated Jakarta Servlet methods and classes – swaps out APIs removed in Servlet 6.0, renaming calls like
encodeUrl(..)toencodeURL(..)andHttpSession.putValue(..)tosetAttribute(..). - Update
javax-valued annotation attributes – rewrites string attributes that still referencejavax, such asinterfaceName = "javax.jms.Topic"on a@JMSDestinationDefinition.
Beyond these source changes, the recipe also raises the Jakarta EE platform dependencies to 10.0.0, removes deprecated CDI 4.0 APIs, upgrades supporting libraries (Jersey 3.1, EclipseLink 4.x, Apache Shiro 2.0, Eclipse Yasson 3.0, and Apache Commons Email2 and FileUpload2), migrates Jakarta Faces to 4.x, upgrades Jetty EE9 to EE10, and updates build plugins in your Maven and Gradle files. For the complete list of sub-recipes, see the recipe catalog page.
Example
Here is a small servlet helper before and after JakartaEE10 runs:
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
class SessionHandler {
void store(HttpSession session, String userId) {
session.putValue("user", userId);
}
String redirect(HttpServletResponse response, String url) {
return response.encodeUrl(url);
}
}
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
class SessionHandler {
void store(HttpSession session, String userId) {
session.setAttribute("user", userId);
}
String redirect(HttpServletResponse response, String url) {
return response.encodeURL(url);
}
}
Running the recipe
- Moderne Platform
- Moderne CLI
- Sign in to your Moderne tenant or app.moderne.io.
- (Optionally) Use the Organization selector to scope the run to the repositories you want to upgrade.
- Search for the
Migrate to Jakarta EE 10recipe (Moderne Platform link). - Click Dry run.
For a step-by-step walkthrough of the Moderne Platform UI, see Quickstart: Using the Moderne Platform.
Make sure you have built or downloaded Lossless Semantic Trees (LSTs) for the repositories you want to upgrade.
This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI.
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe JakartaEE10
If the recipe is not available locally, then you can install it using:
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-java:3.36.0
Reviewing and committing the changes
Running the recipe never modifies your source repositories directly. Instead, the changes are presented as a diff that you can inspect before deciding what to commit. Review them with whatever workflow fits your team, then use the Moderne Platform's commit options or the mod git CLI commands to push the changes across the affected repositories.
Additional reading
- Migrate to Spring Boot 3 – Spring Boot 3 builds on this same
javax.*tojakarta.*move, so start there if you are upgrading Spring applications. - Tracking migrations – use data tables and visualizations to track the rollout of a Jakarta EE 10 upgrade across many repositories.