title: Deploying war file to Jetty in Docker: Error 404 Not found, but contexts are known
body: <p>I am going through the Hello World tutorial for Jetty <a href="https://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld#Building_a_WAR_file" rel="nofollow noreferrer">here</a> </p>
  
  <p>According to the tutorial, I should be able to access it at :8080/hello-world/hello (hello-world comes from the artifact ID in the pom.xml, and hello comes from the web.xml).  When I try this, I get a HTTP Error 404.  </p>
  
  <p>When I try to access the web server at <a href="http://172.17.0.2:8080/" rel="nofollow noreferrer">http://172.17.0.2:8080/</a> (172.17.0.2 is the container's ip address) I get the following information displayed:</p>
  
  <pre><code>Error 404 - Not Found.
  No context on this server matched or handled this request.
  Contexts known to this server are:
  
   - /hello-world-0.1-SNAPSHOT ---&gt; o.e.j.w.WebAppContext@3224f60b{hello-world-0.1-SNAPSHOT,/hello-world-0.1-SNAPSHOT,file:///tmp/jetty-0.0.0.0-8080-hello-world-0.1-SNAPSHOT.war-_hello-world-0.1-SNAPSHOT-any-4591378293374546697.dir/webapp/,AVAILABLE}{/hello-world-0.1-SNAPSHOT.war}
  
  
  </code></pre>
  
  <p>My Dockerfile:</p>
  
  <pre><code>
  FROM openjdk:10 as step-one                                                                                                 
  
  COPY ./ /var/www/java/
  WORKDIR /var/www/java
  
  RUN apt-get update -y &amp;&amp; apt-get install -y maven
  
  RUN mvn clean package -X
  
  FROM jetty as step-two
  
  COPY --from=step-one /var/www/java/target/hello-world-0.1-SNAPSHOT.war /var/lib/jetty/webapps/
  
  ENTRYPOINT ["java"]
  CMD ["-jar", "/usr/local/jetty/start.jar", "--create-startd=jmx, stats"]
  
  EXPOSE 8080
  
  
  </code></pre>
  
  <p>My web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;                                                                                 
  &lt;web-app 
     xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     version="2.5"&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Hello&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.example.HelloServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Hello&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/hello/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>pom.xml:</p>
  
  <pre><code>
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;org.example&lt;/groupId&gt;
    &lt;artifactId&gt;hello-world&lt;/artifactId&gt;
    &lt;version&gt;0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;name&gt;Jetty HelloWorld&lt;/name&gt;
  
    &lt;properties&gt;
      &lt;jettyVersion&gt;7.2.0.v20101020&lt;/jettyVersion&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
        &lt;artifactId&gt;jetty-server&lt;/artifactId&gt;
        &lt;version&gt;${jettyVersion}&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  
    &lt;build&gt;
        &lt;plugins&gt;
  
  
            &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
  
        &lt;plugin&gt;
          &lt;!-- This plugin is needed for the servlet example --&gt;
          &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;${jettyVersion}&lt;/version&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;1.1&lt;/version&gt;
          &lt;executions&gt;
            &lt;execution&gt;&lt;goals&gt;&lt;goal&gt;java&lt;/goal&gt;&lt;/goals&gt;&lt;/execution&gt;
          &lt;/executions&gt;
          &lt;configuration&gt;
            &lt;mainClass&gt;org.example.HelloWorld&lt;/mainClass&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  
  </code></pre>
  
  <p>HelloServlet.java:</p>
  
  <pre><code>
  package org.example;                                                                                                        
  
  import java.io.IOException;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class HelloServlet extends HttpServlet
  {
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
      {   
          response.setContentType("text/html");
          response.setStatus(HttpServletResponse.SC_OK);
          response.getWriter().println("&lt;h1&gt;Hello Servlet&lt;/h1&gt;");
          response.getWriter().println("session=" + request.getSession(true).getId());
      }   
  }
  </code></pre>