title: HTTP Status 404 when testing restful webservice using Jersey
body: <p>I have been trying to develop and deploy a restful web service using Jersey. I have followed the documentation from docs.oracle.com and also various other sources but getting HTTP Status 404 upon testing the service.</p>
  
  <p>Following is my web.xml</p>
  
  <pre class="lang-xml prettyprint-override"><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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;Hello World&lt;/display-name&gt;
  
    &lt;servlet&gt;
        &lt;servlet-name&gt;Hello&lt;/servlet-name&gt;
        &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
        &lt;init-param&gt;
            &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
            &lt;param-value&gt;com.rest.jersey.test&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;Hello&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/resources/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>And this is my service.</p>
  
  <pre><code>package com.rest.jersey.test;
  
  import javax.ws.rs.Path;
  import javax.ws.rs.GET;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  @Path("/hello")
  public class HelloWorld {
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String response(){
              return "Hello World!";
      }
  }
  </code></pre>
  
  <p>When I try to hit the URL</p>
  
  <pre><code>http://localhost:8080/TestRestWithJersey/resources/hello
  </code></pre>
  
  <p>it gives HTTP Status 404 error. Please help me regarding this.</p>
  
  <p>I just checked log file of Eclipse and it doesn't say anything other than this: </p>
  
  <blockquote>
    <p>!MESSAGE No projects found for
    [/workspace/TestRestWithJersey/WebContent/WEB-INF/web.xml]</p>
  </blockquote>
  
  <p>I didn't understand the message, can you help me on this? </p>
  
  <p>Also, the tomcat log when hitting url says</p>
  
  <pre><code>SEVERE: Error loading WebappClassLoader
    context: /TestRestWithJersey
    delegate: false
    repositories:
      /WEB-INF/classes/
  ----------&gt; Parent Classloader:
  org.apache.catalina.loader.StandardClassLoader@5362ab
   com.sun.jersey.spi.container.servlet.ServletContainer
  java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
  </code></pre>
  
  <p>I added jersey-server.jar along with jsr-311.jar</p>
  
  <p>Also tried earlier with single jersey-bundle.jar</p>
  
  <p>The problem is still same.</p>
  
  <p>Any help is appreciated.</p>