title: REST Jersey Tomcat 7
body: <p>Getting 404 error, when accessing the</p>
  
  <p>Hello.java</p>
  
  <pre><code>package de.vogella.jersey.first;
  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("/hello")
  public class Hello {
  
    // This method is called if TEXT_PLAIN is request
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String sayPlainTextHello() {
      return "Hello Jersey";
    }
  
    // 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" + "&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" + "&lt;/title&gt;"
          + "&lt;body&gt;&lt;h1&gt;" + "Hello Jersey" + "&lt;/body&gt;&lt;/h1&gt;" + "&lt;/html&gt; ";
    }
  
  } 
  '
  </code></pre>
  
  <p>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" 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;de.vogella.jersey.first&lt;/display-name&gt;
        &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey REST Service&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;de.vogella.jersey.first&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>This has been taken from the <a href="http://www.vogella.com/tutorials/REST/article.html" rel="nofollow">http://www.vogella.com/tutorials/REST/article.html</a>, but when I run the 
  <code>http://localhost:8080/de.vogella.jersey.first/rest/hello</code></p>
  
  <p>. I get 404 error .</p>
  
  <p>Can someone please help me on this.</p>