title: Jersey: The request resource is not available
body: <p>I am trying to get my first Jersey web service project to work but I am getting this error <code>Jersey: The requested resource is not available.</code> I have installed <code>Jersey 2.16</code> by eclispe Maven and installed <code>Tomcat 8.0.21</code> I have craeted the MessageResource.java class inside <code>scr/main/java - org.test.messanger</code></p>
  
  <p>I am typing this link:</p>
  
  <p><code>http://localhost:8080/messanger/webapi/messages</code></p>
  
  <p>If I klick this link <code>http://localhost:8080/messanger/webapi/myresource</code> I am getting <code>Got it!</code></p>
  
  <p>I added Jersy with maven with this data:</p>
  
  <ul>
  <li>org.glassfish.jersey.archetypes</li>
  <li>jersey-Quickstart-webapp</li>
  <li>2.16</li>
  </ul>
  
  <p>MessageResource.java</p>
  
  <pre><code>import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  
  @Path("/messages")
  public class MessageResource {
  
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String getMessages(){
          return "Hello world";
      }
  
  }
  </code></pre>
  
  <p>Working code:</p>
  
  <pre><code>package org.test.messanger;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  /**
   * Root resource (exposed at "myresource" path)
   */
  @Path("myresource")
  public class MyResource {
  
      /**
       * Method handling HTTP GET requests. The returned object will be sent
       * to the client as "text/plain" media type.
       *
       * @return String that will be returned as a text/plain response.
       */
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String getIt() {
          return "Got it!";
      }
  }
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&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="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&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;org.test.messanger&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>