Sentry Answers>Java>

Java Jakarta Class Not Found

Java Jakarta Class Not Found

Venter C.

The Problem

You encounter the following error in your Java application:

Click to Copy
java.lang.NoClassDefFoundError: jakarta/servlet/http/HttpServletRequest

This error occurs when a class that your application needs at runtime is missing or cannot be found on the classpath. Specifically, it indicates that the jakarta.servlet.http.HttpServletRequest class could not be found.

The Solution

This issue often arises when migrating applications to newer versions of Jakarta EE from Java EE or using newer libraries that depend on jakarta.* package names instead of the javax.* packages.

Let’s ensure that your project is fully compatible with Jakarta EE by checking for the following common problems:

  • Outdated Jakarta Servlet dependencies
  • Compatibility issues in projects built with Java EE
  • Incompatible application servers
  • References to defunct dependencies and libraries
  • Outdated build scripts

Check Dependencies

Ensure that your pom.xml file (for Maven projects) and the corresponding build file for your project management tool contain the correct Jakarta Servlet dependency.

For Jakarta Servlet, you can include the following dependency:

Click to Copy
<dependency> <groupId>jakarta.servlet</groupId> <artifactId>jakarta.servlet-api</artifactId> <version>5.0.0</version> <!-- Ensure that the version matches your needs --> <scope>provided</scope> </dependency>

If you use Gradle, add the following dependency:

Click to Copy
dependencies { implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0' // Adjust version as necessary }

Note: You can adjust the version based on your Jakarta EE requirements.

Check Project Compatability

If your project was originally built using Java EE (javax.*) and your application server or libraries were subsequently upgraded to use Jakarta EE (jakarta.*), you may encounter compatibility issues. Ensure that all project dependencies, modules, and configurations align with Jakarta EE specifications.

Check Application Server Compatibility

Check whether the application server supports the version of Jakarta EE used by your application. Some servers are only compatible with Java EE. Using Jakarta dependencies without proper server support may lead to runtime issues.

Check for Old References

Ensure that there are no outdated dependencies or libraries that still rely on javax.servlet.* classes. Such mixed usage can lead to class resolution problems.

Validate Build Tools and Configurations

If you have a custom build process or use tools like Gradle, ensure that your build scripts reflect the correct dependencies and versions for Jakarta EE.

Further Reading

  • Sentry BlogException Handling in Java (with Real Examples)
  • Syntax.fmListen to the Syntax Podcast
  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2025 • Sentry is a registered Trademark of Functional Software, Inc.