title: Java rest API returns HTTP status 404
body: <p>I have a simple REST API i am trying to get running and it's giving me a HTTP 404 error.  AFAICS it looks right but obv not ...
  Tomcat is running and i get the Eclipse browser come up with HTTP404. Tomcat doesnt help with all its errors but they are all just warnings but i can pop them in here if needed, will clutter the question though.</p>
  
  <p>I think its to do with the jersey format, the xml or both but not sure.</p>
  
  <p>*****Updated the question to include a xml update and a tomcat error.******</p>
  
  <p>My class is thus:</p>
  
  <pre><code>package WS;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  //annotations
  @Path("/book")
  public class Book{
      @GET
      @Produces(MediaType.TEXT_XML)
      public String sayHelloXML(){
          String response = "&lt;?xml version='1.0'?&gt;&lt;hello&gt;Hello there&lt;/hello&gt;";
          return response;
      }
  }
  </code></pre>
  
  <p>My Xml is thus: (note i think im using jersey 2.0 so i dont have to have anything here right?)</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://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
    &lt;display-name&gt;RestApi&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
  
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;MyApplication&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;!-- The package where your resource classes are --&gt;
          &lt;param-value&gt;WS&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyApplication&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>... and my libs imported is thus:
  <a href="https://i.stack.imgur.com/IvmfO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IvmfO.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>SEVERE: Allocate exception for servlet MyApplication
    java.lang.ClassNotFoundException:
    org.glassfish.jersey.servlet.ServletContainer     at
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
      at
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
      at
    org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520)
      at
    org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501)
      at
    org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120)
      at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
      at
    org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:817)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      at
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
      at
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
      at
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)</p>
  </blockquote>
  
  <p>Error i get back in browser when i hit <a href="http://localhost:8080/PK_WS/api/" rel="nofollow noreferrer">http://localhost:8080/PK_WS/api/</a></p>
  
  <blockquote>
    <p>javax.servlet.ServletException: Error instantiating servlet class
    org.glassfish.jersey.servlet.ServletContainer
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)</p>
    
    <p>root cause java.lang.ClassNotFoundException:
    org.glassfish.jersey.servlet.ServletContainer
      org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
      org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)</p>
  </blockquote>