title: Rest Web service 404 error - Tomcat Eclipse
body: <p>This is the first time I'm using Web Services, and it's driving me nuts.</p>
  
  <p>I'm following the tutorial from : <a href="http://www.vogella.com/articles/REST/article.html" rel="nofollow noreferrer">http://www.vogella.com/articles/REST/article.html</a> - section 6</p>
  
  <p>I created the Project Name as example.restservice.blue, and within that I have a package example.restservice.blue and within that I have a class Hey:</p>
  
  <pre><code>package example.restservice.blue;
  
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  // Plain old Java Object it does not extend as class or implements 
  // an interface
  
  // The class registers its methods for the HTTP GET request using the @GET annotation. 
  // Using the @Produces annotation, it defines that it can deliver several MIME types,
  // text, XML and HTML. 
  
  // The browser requests per default the HTML MIME type.
  
  //Sets the path to base URL + /hello
  @Path("/Hey")
  public class Hey {
  
  // This method is called if TEXT_PLAIN is request
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public String sayPlainTextHello() {
  return "Hello Jersey, please please work";
  }
  
   // This method is called if XML is request
   @GET
  @Produces(MediaType.TEXT_XML)
  public String sayXMLHello() {
  return "&lt;?xml version=\"1.0\"?&gt;" + "&lt;hello&gt; Hello Jersey, please please work" + "&lt;/hello&gt;";
  }
  
  // This method is called if HTML is request
  @GET
  @Produces(MediaType.TEXT_HTML)
  public String sayHtmlHello() {
  return "&lt;html&gt; " + "&lt;title&gt;" + "Hello Jersey, please please work" + "&lt;/title&gt;"
      + "&lt;body&gt;&lt;h1&gt;" + "Hello Jersey, please please work" + "&lt;/body&gt;&lt;/h1&gt;" + "&lt;/html&gt; ";
  }
  
  }
  </code></pre>
  
  <p>Above is the resources java file.</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" id="WebApp_ID" version="3.0"&gt;
  &lt;display-name&gt;example.restservice.blue&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
  &lt;/welcome-file-list&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;init-param&gt;
      &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
      &lt;param-value&gt;example.restservice.blue&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 REST Service&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Above is the web.xml file.</p>
  
  <p>The project is named as example.restservice.blue as well.</p>
  
  <p>The class file is present in example.restservice.blue/build/classes/example/restservice/blue/
  The web.xml file is present is example.restservice.blue/WebContent/WEB-INF/</p>
  
  <p>Tomcat 7 runs fine with another application and also displays the tomcat welcome page, so there are no issues with it, I think.</p>
  
  <p>here is the error i get:</p>
  
  <p><img src="https://i.stack.imgur.com/wERb0.png" alt="Error 404"></p>
  
  <p>Here is the console:</p>
  
  <p>></p>
  
  <pre><code>Nov 07, 2014 5:34:37 PM org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\QuickTime\QTSystem\;.
  Nov 07, 2014 5:34:38 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:example.restservice.bhagya' did not find a matching property.
  Nov 07, 2014 5:34:38 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  Nov 07, 2014 5:34:38 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Nov 07, 2014 5:34:38 PM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 1608 ms
  Nov 07, 2014 5:34:38 PM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Nov 07, 2014 5:34:38 PM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
  Nov 07, 2014 5:34:38 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
  INFO: validateJarFile(C:\Users\vaio\Desktop\RESTProject\wtpwebapps\example.restservice.blue\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
  Nov 07, 2014 5:34:42 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory C:\Users\vaio\Desktop\RESTProject\webapps\docs
  Nov 07, 2014 5:34:42 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory C:\Users\vaio\Desktop\RESTProject\webapps\examples
  Nov 07, 2014 5:34:42 PM org.apache.catalina.core.ApplicationContext log
  INFO: ContextListener: contextInitialized()
  Nov 07, 2014 5:34:42 PM org.apache.catalina.core.ApplicationContext log
  INFO: SessionListener: contextInitialized()
  Nov 07, 2014 5:34:42 PM org.apache.catalina.core.ApplicationContext log
  INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@53d4287')
  Nov 07, 2014 5:34:42 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory C:\Users\vaio\Desktop\RESTProject\webapps\host-manager
  Nov 07, 2014 5:34:42 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory C:\Users\vaio\Desktop\RESTProject\webapps\manager
  Nov 07, 2014 5:34:42 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory C:\Users\vaio\Desktop\RESTProject\webapps\ROOT
  Nov 07, 2014 5:34:42 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Nov 07, 2014 5:34:42 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Nov 07, 2014 5:34:42 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 4642 ms
  </code></pre>