// Turn off XML validation.
System.setProperty("org.mortbay.xml.XmlParser.Validating", "false");
Server server = new Server();
AbstractConnector connector = getConnector(logger);
setupConnector(connector, bindAddress, port);
server.addConnector(connector);
// Create a new web app in the war directory.
WebAppContext wac = createWebAppContext(logger, appRootDir);
RequestLogHandler logHandler = new RequestLogHandler();
logHandler.setRequestLog(new JettyRequestLogger(logger, getBaseLogLevel()));
logHandler.setHandler(wac);
server.setHandler(logHandler);
server.start();
server.setStopAtShutdown(true);
// Now that we're started, log to the top level logger.
Log.setLog(new JettyTreeLogger(logger));
// DevMode#doStartUpServer() fails from time to time (rarely) due
// to an unknown error. Adding some logging to pinpoint the problem.
int connectorPort = connector.getLocalPort();
if (connector.getLocalPort() < 0) {
branch.log(TreeLogger.ERROR, String.format(
"Failed to connect to open channel with port %d (return value %d)",
port, connectorPort));
if (connector.getConnection() == null) {
branch.log(TreeLogger.TRACE, "Connection is null");
}
}
return createServletContainer(logger, appRootDir, server, wac,