title: Deploying Jetty server via .jar. Why can't I access the index?
body: <p>I'm trying to deploy a Jetty server from a jar file. When jar is being run on the server, it reaches the Jetty 404 page at least, but is unable to reach <code>index.html</code>.</p>
  
  <p>My main class to launch the server looks like this, and works fine locally when run through the IDE on localhost:</p>
  
  <pre><code>public static void main(String[] args) {
      Server server = new Server(8080);
  
      ServletContextHandler servletContextHandler = new ServletContextHandler(NO_SESSIONS);
      servletContextHandler.setContextPath("/");
  
      DefaultServlet defaultServlet = new DefaultServlet();
      ServletHolder holderPwd = new ServletHolder("default", defaultServlet);
  
      final URL htmlDirectory = JerseyApplication.class.getResource("/html");
  
      holderPwd.setInitParameter("resourceBase", htmlDirectory.getFile());
  
      servletContextHandler.addServlet(holderPwd, "/*");
      server.setHandler(servletContextHandler);
  
      ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/api/*");
      servletHolder.setInitOrder(0);
      servletHolder.setInitParameter(
              "jersey.config.server.provider.packages",
              "com.x.y.z.parser");
  
      try {
          LOGGER.info("Starting server");
          server.start();
          server.join();
      }
      catch (Exception ex) {
          LOGGER.error("Server failed to start - Aborting");
          ex.printStackTrace();
      }
      finally {
          LOGGER.info("Destroying server");
          server.destroy();
      }
  }
  </code></pre>
  
  <p>All html stuff is in a the <code>src/main/resources/html</code> directory.</p>
  
  <p>When I run <code>jar tvf jarfile.jar | grep html</code> I can see the <code>html</code> directory and it's contents are in there:</p>
  
  <pre><code>0 Thu Nov 01 11:48:46 UTC 2018 html/
  2258 Thu Nov 01 11:48:46 UTC 2018 html/formRequest.js
  871 Thu Nov 01 11:48:46 UTC 2018 html/index.html
  </code></pre>
  
  <p>Thanks!</p>