title: 404 Error with RESTful webservice using Jersey
body: <p>I have been spending hours trying to figure out why I am gettin 404 error. I have checked similar postings in Stackoverflow, but I am still having a problem.</p>
  
  <p>I know it runs on Tomcat and can display index file. But, when I try to test RESTful ws with the following url, <a href="http://localhost:8080/RestWs/rest/hello" rel="nofollow noreferrer">http://localhost:8080/RestWs/rest/hello</a>, 
  I get 404 error:</p>
  
  <p>My web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt;
    &lt;display-name&gt;RestWs&lt;/display-name&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;context-param&gt;
      &lt;description&gt;State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2&lt;/description&gt;
      &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
      &lt;param-value&gt;client&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
      &lt;param-name&gt;javax.servlet.jsp.jstl.fmt.localizationContext&lt;/param-name&gt;
      &lt;param-value&gt;resources.application&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;com.sun.faces.config.ConfigureListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>My resource class in Java:
  package DemoRest;</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("/hello")
  public class HelloResource {
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String sayHello() {
          return "Hello Jersey";
      }
  }
  </code></pre>
  
  <p>I downloaded Jersey jars from <a href="https://jersey.github.io/download.html#" rel="nofollow noreferrer">https://jersey.github.io/download.html#</a> 
  and copied the jars in the WEB/INF/lib folder.
  The extracted jaxrs-ri-2.26 jar has three folders - api, ext and lib. I copied all jars from these folders to the WEB/INF/lib folder.</p>
  
  <p>I am wondering if I am missing some jars or they are not in a right location. However, I checked most of the related postings in the stackoverflow for solution, but I was not successful. </p>
  
  <p>I appreciate any help. </p>