title: jersey/tomcat Description The origin server did not find a current representation for the target resource
body: <p>I have configured jersey (with tomcat server) according to the details described until step 6.3 here:
  <a href="http://www.vogella.com/tutorials/REST/article.html#jerseyprojectsetup" rel="noreferrer">http://www.vogella.com/tutorials/REST/article.html#jerseyprojectsetup</a></p>
  
  <p>Below is my web.xml file, the only difference is that the path/package name for the <code>jersey.config.server.provider.packages</code></p>
  
  <p>the instructions has;</p>
  
  <pre><code>&lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
          &lt;param-value&gt;com.vogella.jersey.first&lt;/param-value&gt;
  </code></pre>
  
  <p>because <code>com.vogella.jersey.first</code> is their package name, while I chose to point mine to my default package (jerseytest)</p>
  
  <p>but this is 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" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;jerseytest&lt;/display-name&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;!-- Register resources and providers under com.vogella.jersey.first package. --&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
          &lt;param-value&gt;jerseytest&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>when I run the application on the tomcat server I keep getting: </p>
  
  <blockquote>
    <p>HTTP Status 404 – Not Found</p>
    
    <p>Type Status Report</p>
    
    <p><code>Message /jerseytest/</code></p>
    
    <p>Description The origin server did not find a current representation
    for the target resource or is not willing to disclose that one exists.</p>
    
    <p>Apache Tomcat/8.5.23</p>
  </blockquote>
  
  <p>and when i point the browser to the end point mentioned in the tutorial : 
  <code>http://localhost:8080/com.vogella.jersey.first/rest/hello</code></p>
  
  <p>I get a not found error:</p>
  
  <blockquote>
    <p>HTTP Status 404 – Not Found</p>
    
    <p>Type Status Report</p>
    
    <p><code>Message Not Found</code></p>
    
    <p>Description The origin server did not find a current representation
    for the target resource or is not willing to disclose that one exists.</p>
    
    <p>Apache Tomcat/8.5.23</p>
  </blockquote>
  
  <p>When I point the browser directly to <a href="http://localhost:8080/rest/hello" rel="noreferrer">http://localhost:8080/rest/hello</a></p>
  
  <p>I get:</p>
  
  <blockquote>
    <p>HTTP Status 404 – Not Found</p>
    
    <p>Type Status Report</p>
    
    <p><code>Message /rest/hello</code></p>
    
    <p>Description The origin server did not find a current representation
    for the target resource or is not willing to disclose that one exists.</p>
    
    <p>Apache Tomcat/8.5.23</p>
  </blockquote>
  
  <p>My java class is identical to the example in the instructions , except that mine  is in the default package :</p>
  
  <pre><code>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>