🔴 The Error You're Seeing
Confirm this matches your console output. If it does, you're in the right place.
2026-02-14 19:15:20.000 ERROR 8842 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: java.lang.NoClassDefFoundError: jakarta/servlet/http/HttpServlet
Caused by: java.lang.ClassNotFoundException: jakarta.servlet.http.HttpServlet⚡ Quick Fix Works 80% of the time
Change all javax.servlet.* imports to jakarta.servlet.* in your Java code.
// Change this:
// import javax.servlet.http.HttpServletRequest;
// To this:
import jakarta.servlet.http.HttpServletRequest;🧠 Why this Happens
Tap to expand the deep technical explanation
Spring Boot 3.x uses the Jakarta EE 9+ namespaces instead of the old Java EE javax namespaces. The JVM is trying to load a class using the new jakarta path, but it cannot find it because either your code or a dependency is still providing the old javax classes.
The HITEC City Parking Spot Analogy:
It is like trying to use a key from an old house (javax) on the door of a newly built house (jakarta). The shape is slightly different, so the lock (Spring Boot 3) rejects it.
🔁 How to Reproduce Confirm this is your error
Use a Spring Boot 2.x-era dependency that imports javax.servlet.* classes in a Spring Boot 3 application, then start the app. You get ClassNotFoundException: jakarta.servlet.http.HttpServlet.
🛠️ Solutions (3 Ways to Fix)
Update imports from javax to jakarta
👉 Use this when migrating an existing app to Spring Boot 3.
Spring Boot 3 migrated from Java EE (javax.*) to Jakarta EE (jakarta.*). You must update all imports in your Java files.
// Old (Spring Boot 2.x)
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;
// New (Spring Boot 3.x)
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;Upgrade third-party dependencies
👉 Use this if your code is correct, but a library you are using still relies on javax.
Libraries like SpringDoc OpenAPI, Lombok, or older Swagger versions must be upgraded to versions that support Spring Boot 3 and Jakarta EE.
<!-- Upgrade SpringDoc for Spring Boot 3 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>Ensure Java 17+ is being used
👉 Use this if your build fails with package does not exist errors.
Spring Boot 3 requires a minimum of Java 17. Ensure your pom.xml and IDE are configured to use Java 17 or 21.
<properties>
<java.version>17</java.version>
</properties>📋 Version Notes
Uses javax.servlet, javax.persistence, etc.
Completely removed javax. Uses jakarta.servlet, jakarta.persistence, etc.
🛡️ How to Prevent This Next Time
When upgrading to Spring Boot 3, use the OpenRewrite migration tool to automatically handle javax to jakarta package replacements.