public static void run(URL warUrl, boolean consoleMode, String[] args)
      throws Exception {

    if (args.length == 0 || isHelp(args)) {
      BootstrapCommon.printUsage(WebappBootstrapMain.class, "usage-webapp.txt");
      System.exit(-1);
    }

    Options options = createOptions();
    Parser parser = new GnuParser();

    CommandLine cli = parser.parse(options, args);
    args = cli.getArgs();

    if (args.length != 1) {
      BootstrapCommon.printUsage(WebappBootstrapMain.class, "usage-webapp.txt");
      System.exit(-1);
    }

    String bundlePath = args[0];
    System.setProperty("bundlePath", bundlePath);

    int port = 8080;
    if (cli.hasOption(ARG_PORT))
      port = Integer.parseInt(cli.getOptionValue(ARG_PORT));

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(port);
    server.setConnectors(new Connector[] {connector});

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");
    context.setWelcomeFiles(new String[] {"index.action"});
    context.setWar(warUrl.toExternalForm());
    // We store the command line object as a webapp context attribute so it can
    // be used by the context loader to inject additional beans as needed
    context.setAttribute(WebappCommon.COMMAND_LINE_CONTEXT_ATTRIBUTE, cli);
    server.setHandler(context);

    /**
     * We specify a Jetty override descriptor to inject additional definitions
     * into our web.xml configuration. Specifically, we specify a
     * <context-param> to specify the "contextClass" that will be used to create
     * our Spring ApplicationContext. We create a custom version that will
     * inject additional beans based on command-line arguments.
     */
    context.addOverrideDescriptor("/WEB-INF/override-web.xml");

    if (cli.hasOption(WebappCommon.ARG_BUILD)) {
      System.setProperty("hibernate.hbm2ddl.auto", "update");
      System.setProperty("bundleCacheDir", bundlePath + "/cache");
      System.setProperty("gtfsPath",
          cli.getOptionValue(WebappCommon.ARG_GTFS_PATH));
      context.addOverrideDescriptor("/WEB-INF/builder-override-web.xml");
    }

    try {
      server.start();

      System.err.println("=============================================================");
      System.err.println("=");
      System.err.println("= Your OneBusAway instance has started.  Browse to:");
      System.err.println("=");
      System.err.println("= http://localhost:8080/");
      System.err.println("=");
      System.err.println("= to see your instance in action.");
      if (consoleMode) {
        System.err.println("=");
        System.err.println("= When you are finished, press return to exit gracefully...");
      }
      System.err.println("=============================================================");

      if (consoleMode) {
        System.in.read();
        server.stop();
        server.join();
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(100);
    }
  }