javax.servlet.ServletException: Class [org.glassfish.jersey.servlet.ServletContainer] is not a Servlet

2k Views Asked by At

You may feel this is a duplicated question, but none of the questions with the same title solve my problems. I am using Jersey 3.0 creating a RESTful web service in Eclipse, I use Tomcat 9.0 as my server.

1

There are 1 best solutions below

0
On

Jersey 3.x uses Servlet 5.0, which now uses the Jakarta naming. All the javax.servlet packaging has now changed to jakarta.servlet. The Jersey ServletContainer now extends jakarta.servlet.http.HttpServlet; it is not javax anymore. The first Tomcat to use Jakarta is Tomcat 10.x; Tomcat 9.x still uses the javax.servlet packaging. So if you want to use Jersey 3.x, then you should upgrade your Tomcat to 10.x.