I am new in jakarta EE /webservice. While running on Tomcat 9 server with the following resource, I am getting error java.lang.ClassNotFoundExceptio
java.lang.ClassNotFoundException: jakarta.servlet.Filter
This class is part of Servlet API version 5.0 which in turn is part of Jakarta EE version 9.
And,
3.0.0-M6
this Jersey version is based off JAX-RS API version 3.0 which in turn is part of Jakarta EE version 9.
And,
Tomcat 9 server
this Tomcat version is based off Servlet API version 4.0 which in turn is part of Java/Jakarta EE version 8.
So, summarized, the targeted JEE versions don't match up and it's causing trouble for you. You have 2 options:
Downgrade Jersey to version 2.x. This one is based off JAX-RS API version 2.x which in turn is part of Java/Jakarta EE version 8.
Or, upgrade Tomcat to version 10.x. This one is based off Servlet API version 5.0 which in turn is part of Jakarta EE version 9 (which in turn offers JAX-RS API version 3.x for which you can thus use the intended Jersey version).
The technical reason is that during the step from Java/Jakarta EE 8 to Jakarta EE 9 all javax.* packages have been renamed to jakarta.* packages. So there is no backwards compatibility anymore since Jakarta EE 9. The target runtime itself (thus, Tomcat itself), has really to be the one targeted for the APIs in use by Jakarta EE 9.