title: How to startup Jetty Embedded as part of a Jenkins build
body: <p>I have a webapp which uses Jetty as it's embedded application server. I have also set up a Main class for it, which starts the server when I run it using the following command:</p>
  
  <pre><code>java -jar foo.war
  </code></pre>
  
  <p>To this part everything is working as expected. The problem I'm currently having is while integrating this with Jenkins.</p>
  
  <p>If I execute <code>java -jar foo.war</code> as a batch command, the server starts but the build doesn't finish - it just keeps showing the server console (it makes sense after all, since everything is part of the same process). I guess I'm supposed to spawn a new process, but <strong>how do I spawn a new process and "notify" the main process after the server was started?</strong></p>
  
  <p>I need to run my acceptance tests (aka selenium tests) only after the application server was started.</p>
  
  <p>Jenkins is running (unfortunately) under Windows Server. Not sure if that's relevant, but below is the code which I use to start the application server (slightly simplified):</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
    Server server = new Server(8082);
    server.setHandler(getHandlers(server));
    server.setStopAtShutdown(true);
    server.start();
    server.join();
  }
  
  private static HandlerList getHandlers(Server server) {
    ProtectionDomain protectionDomain = WebServer.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    WebAppContext webapp = new WebAppContext(location.toExternalForm(), "/");
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
      webapp
    });
   return handlers;
  }
  </code></pre>