Tomcat 10.x throws java.lang.NoClassDefFoundError on javax.servlet.* [duplicate]

C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\conf\Catalina\localhost\VirtualStore.xml

You’re thus using Tomcat 10.x which is based off Servlet API version 5.0 which in turn is part of Jakarta EE version 9.

java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener

This is unexpected. The javax.* package has been renamed to jakarta.* package since Jakarta EE version 9. This thus means that the deployed web application is actually not compatible with Jakarta EE version 9. The deployed web application is most likely developed for an older JEE version where the javax.* package is still used.

So, summarized, the targeted JEE versions don’t match up and it’s causing trouble for you. You have 2 options:

  1. Downgrade Tomcat to version 9.x. This is the latest available version which still uses the javax.* package.

  2. Or, upgrade the deployed web application to target Jakarta EE 9 instead. I.e. adjust the project’s dependencies (e.g. pom.xml) to reference JEE 9+ based versions instead, and perform a project-wide Find & Replace of javax.* to jakarta.* (of course except for javax.naming.* and javax.xml.* and probably a few others, but the Java compiler will quickly point out them for you).

See also:

Leave a Comment