๐Ÿ”ด The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG2026-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;

๐Ÿ› ๏ธ Solutions (3 Ways to Fix)

Solution 1โœ“ Most common cause

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;
Solution 2

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>
Solution 3

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

Spring Boot 2.x

Uses javax.servlet, javax.persistence, etc.

Spring Boot 3.x

Completely removed javax. Uses jakarta.servlet, jakarta.persistence, etc.

๐Ÿง  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 Prevent This Next Time

When upgrading to Spring Boot 3, use the OpenRewrite migration tool to automatically handle javax to jakarta package replacements.

Course Search
Search across all chapters & stages
๐Ÿ“–

Search the course

Type any topic โ€” branching, stash, rebase, hooks โ€” and jump straight to that chapter.

merge branchesgit stashundo commitrebase