title: SEVERE: Servlet [Jersey Web Application] in web application [/restapp] threw load() exception
body: <p>This is my REST API project. I don't know what this error is. I am trying resolve this error from two days now and i am exhausted now, anyone help me here</p>
  <p>web page is loading but this error is showing in console</p>
  <pre><code> SEVERE: Servlet [Jersey Web Application] in web application [/restapp] threw load() exception
  java.lang.ClassNotFoundException: jakarta.servlet.Filter
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
      at java.base/java.lang.ClassLoader.defineClass1(Native Method)
      at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
      at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
      at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2418)
      at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:865)
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1334)
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
      at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:539)
      at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:520)
      at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1042)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4864)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
      at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
      at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
      at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
      at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
      at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
      at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
      at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:567)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
  
  Jun 26, 2020 6:33:03 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler [&quot;http-nio-8080&quot;]
  Jun 26, 2020 6:33:03 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in [1,110] milliseconds
  </code></pre>
  <p>this is my pom.xml file</p>
  <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;shrikant&lt;/groupId&gt;
      &lt;artifactId&gt;restapp&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;restapp&lt;/name&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;restapp&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5.1&lt;/version&gt;
                  &lt;inherited&gt;true&lt;/inherited&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.glassfish.jersey&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-bom&lt;/artifactId&gt;
                  &lt;version&gt;${jersey.version}&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
              &lt;!-- use the following artifactId if you don't need servlet 2.x compatibility --&gt;
              &lt;!-- artifactId&gt;jersey-container-servlet&lt;/artifactId --&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;!-- uncomment this to get JSON support
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-json-binding&lt;/artifactId&gt;
          &lt;/dependency&gt;
          --&gt;
      &lt;/dependencies&gt;
      &lt;properties&gt;
          &lt;jersey.version&gt;3.0.0-M6&lt;/jersey.version&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>
  <p>this is my web.xml file</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!-- This web.xml file is not required when using Servlet 3.0 container,
       see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html --&gt;
  &lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;shrikant.restapp&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/webapi/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  <p>index.jsp</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!-- This web.xml file is not required when using Servlet 3.0 container,
       see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html --&gt;
  &lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;shrikant.restapp&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/webapi/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  <p>And after clicking on the Jersey Resource
  this error is thrown</p>
  <p><a href="https://i.stack.imgur.com/PdH69.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PdH69.png" alt="on the web page" /></a></p>
  <p>At last this is my MyResource.java file</p>
  <pre><code>package shrikant.restapp;
  
  import jakarta.ws.rs.GET;
  import jakarta.ws.rs.Path;
  import jakarta.ws.rs.Produces;
  import jakarta.ws.rs.core.MediaType;
  
  /**
   * Root resource (exposed at &quot;myresource&quot; path)
   */
  @Path(&quot;myresource&quot;)
  public class MyResource {
  
      /**
       * Method handling HTTP GET requests. The returned object will be sent
       * to the client as &quot;text/plain&quot; media type.
       *
       * @return String that will be returned as a text/plain response.
       */
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String getIt() {
          return &quot;Got it!&quot;;
      }
  }
  </code></pre>