Scrivio Interview library
DebuggingIntermediate6 min read · updated 12 November 2026

A Spring Boot 3 application migrated from Boot 2 fails at startup with java.lang.NoClassDefFoundError: javax/servlet/Filter coming from a third-party library. What is going on and what are your options?

Spring Boot 3 is built on Jakarta EE 9 and later, where the Servlet API lives in the jakarta.servlet package instead of javax.servlet. The third-party library was compiled against javax.servlet.Filter, which no longer exists on the class path, so the JVM throws NoClassDefFoundError as soon as it links the library's class. The options are a Jakarta-compatible release of the library, which is the real fix, bytecode rewriting with the Eclipse Transformer as a stopgap, or replacing the library; adding javax.servlet-api back does not help, because the embedded server only understands jakarta.servlet types.

Why this question is asked

The move from javax to jakarta is the biggest source of breakage in a Spring Boot 2 to 3 migration, and it shows up most often in third-party libraries we cannot simply edit. The error message makes it look like a missing jar, which tempts people to add one, and that makes things worse. Interviewers ask this to see whether we understand the namespace change and can choose a sensible path. In this answer, we will recap the change, see exactly why the error happens, walk through the options with their costs, and explain why adding the old API jar back does not work.

1A Quick Recap of the javax to jakarta Change

Java EE, the specification behind servlets, JPA, Bean Validation and more, was handed to the Eclipse Foundation in 2017 and renamed Jakarta EE. Because the javax namespace could not be used for new versions, Jakarta EE 9 renamed every package from javax.* to jakarta.*: javax.servlet.Filter became jakarta.servlet.Filter, javax.persistence.Entity became jakarta.persistence.Entity, and so on. The API is otherwise nearly identical, but to the JVM these are completely different classes.

Spring Boot 2 used the javax packages. Spring Boot 3 requires Jakarta EE 9 or later, with Jakarta EE 10 as its baseline, and Spring Boot 4 moves to Jakarta EE 11. Its embedded Tomcat, Jetty or Undertow implement only jakarta.servlet.

2Why the Error Happens

The library's class files were compiled against the old API, so they contain references to javax/servlet/Filter. Our application no longer has any jar providing that class.

Java
// inside the third-party jar, compiled years ago
public class AuditFilter implements javax.servlet.Filter { ... }
// our Spring Boot 3 configuration
@Bean
FilterRegistrationBean<?> audit() { return new FilterRegistrationBean<>(new AuditFilter()); }
// java.lang.NoClassDefFoundError: javax/servlet/Filter
// at java.base/java.lang.ClassLoader.defineClass1(Native Method)
// ... at com.vendor.audit.AuditFilter ...
// Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
Step throughChoosing a path for a javax-only library
  1. Does a Jakarta-compatible release exist?new major version, or a -jakarta artifact
    YesUpgrade to itNoLook further
  2. Is there a maintained alternative?
    YesReplace the libraryNoConsider transforming
  3. Rewrite the jar with the Eclipse Transformerstopgap: we now own a modified binary
  4. Plan the replacement in the migration backlogdo not leave it permanent

4 steps in order. Play them, or step through them one at a time.

When the JVM defines AuditFilter, it must load its interface, javax.servlet.Filter, and no loader can find it. The library's code is fine; it simply targets an API our platform no longer uses. Any library class that mentions javax.servlet types in its signatures, its superclasses or its method bodies will fail the same way when first used.

3Option 1: A Jakarta-Compatible Version

Most maintained libraries have published Jakarta-compatible releases, often as a new major version, and sometimes as a separate artifact or classifier, such as a name ending in -jakarta, while the old one stays on javax for existing users. The release notes or the project's migration guide usually say which version first supports Jakarta EE 9 or Spring Boot 3. This is the real fix: the library's own maintainers compiled and tested it against the new API.

Sometimes the upgrade has its own breaking changes, because projects took the opportunity of a major version to clean up other APIs, so it should be budgeted as real work, not a version bump.

4Option 2: The Eclipse Transformer as a Stopgap

If no Jakarta version exists and we cannot replace the library immediately, the Eclipse Transformer can rewrite the jar's bytecode and resources, renaming javax references to jakarta.

Shell
$ java -jar org.eclipse.transformer.cli-<version>.jar \
vendor-audit-1.8.jar vendor-audit-1.8-jakarta.jar
// rewrites javax.servlet -> jakarta.servlet in class files, service files and descriptors
// publish the result to our internal repository and depend on it instead of the original

It works surprisingly often, because the APIs are so similar. But it is a stopgap with a support risk. We now ship a binary the vendor never built or tested, nobody will fix bugs in it for us, the transformation can miss references built from strings, such as class names in configuration or reflection, and every new release of the library must be transformed again. It also cannot help if the library relies on javax APIs whose behaviour changed in later Jakarta versions. So we record it as technical debt with an owner and a plan to replace it.

5Why Adding javax.servlet-api Back Does Not Help

The obvious reaction to the error is to add the old javax.servlet-api jar as a dependency. That makes the NoClassDefFoundError go away, because javax.servlet.Filter now exists, but it does not make the library work. The embedded Tomcat in Boot 3 calls filters through jakarta.servlet.Filter, and a class that implements javax.servlet.Filter is not a jakarta.servlet.Filter, so it cannot be registered with the server, and requests the server creates are jakarta.servlet.http.HttpServletRequest objects that the library's javax-typed methods cannot accept. The error simply moves, to a compile error in our configuration, a ClassCastException, or a filter that is silently never invoked, and the application now carries two incompatible copies of the API.

This is why the migration plan should include an inventory of every dependency that references javax.servlet, javax.persistence and the other renamed packages, found with a dependency report or by scanning jars, before switching the Boot version. Unmaintained libraries in that list are candidates for replacement as part of the migration, not after it.

6Follow-up questions

How can we find all javax dependencies before migrating?

Run the dependency tree and look for artifacts known to use the old namespace, such as javax.servlet-api, javax.persistence-api and older Hibernate Validator, then scan the jars themselves, for example with jdeps, which reports package dependencies per jar, or a simple scan for javax/servlet references in class files. OpenRewrite's Spring Boot 3 migration recipes also help with our own code, though third-party jars still need the steps above.

Are all javax packages renamed?

No. Only the Java EE packages moved to jakarta. Packages that are part of the JDK itself, such as javax.crypto, javax.net.ssl, javax.sql and javax.naming, keep their javax names and continue to work.

7Conclusion

In this answer, we saw that Spring Boot 3 runs on Jakarta EE 9 and later, where the Servlet API moved from javax.servlet to jakarta.servlet, so a library compiled against javax.servlet.Filter fails with NoClassDefFoundError when its classes are linked. The real fix is a Jakarta-compatible version of the library, the Eclipse Transformer can rewrite its bytecode as a stopgap with support risk, and replacing unmaintained libraries belongs in the migration plan. Adding javax.servlet-api back only hides the error, because the embedded server works exclusively with jakarta.servlet types.

What to say in the interviewAbout 90 seconds aloud

Open with

Spring Boot 3 moved to Jakarta EE 9 and later, where every Java EE package was renamed from javax to jakarta, so the Servlet API is now jakarta.servlet.

Then, if they want more

The third-party library was compiled against javax.servlet.Filter, which nothing on our class path provides any more, so when the JVM defines the library's filter class and tries to load its interface, it throws NoClassDefFoundError: javax/servlet/Filter. The library code itself is fine, it just targets the old namespace.

My first option is a Jakarta-compatible version of the library, which is often a new major version or a separate artifact with a jakarta suffix. That is the real fix, because the maintainers built and tested it. If there is none, I would look for a maintained alternative and replace it.

As a stopgap, the Eclipse Transformer can rewrite the jar's bytecode from javax to jakarta, and it often works, but we then own a modified binary the vendor never tested, it can miss string-based references, and every upgrade must be transformed again, so I would track it as debt.

What does not help is adding javax.servlet-api back: the error disappears, but Boot 3's embedded Tomcat only works with jakarta.servlet types, so a javax filter still cannot be registered or receive requests. I would also inventory all javax dependencies before the migration and plan to replace unmaintained ones as part of it.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3, Jakarta EE 9, Spring Boot 2, Jakarta EE 10
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A Spring Boot 3 application migrated from Boot 2 fails at startup with...": https://scrivio-interview-library.netlify.app/java/class-loading/5a98650690/