У меня приложение Spring, работающее поверх Jetty.Недавно мы обновили версию Jetty, которая используется с 6.x, до последней стабильной версии 9.4.14
Все, казалось, было настроено и работало хорошо, пока мы не приступили к сборке версии приложения.При загрузке Jetty требуется 12 минут для запуска Сервера!
Мой журнал:
2019-02-08 14:54:15,917 INFO [ContextHandler] Started o.e.j.w.WebAppContext@1f554b06{RTD2,/web,file:///data/XXX/war/,AVAILABLE}{/data/XXX/war}
2019-02-08 14:54:16,123 INFO [SslContextFactory] x509=X509@33beb1(1,h=[XXX.co.uk],w=[XXX.co.uk]) for SslContextFactory@480f6625[provider=null,keyStore=file:///data/XX/config/keystore2,trustStore=file:///etc/ssl/certs/java/cacerts]
2019-02-08 15:07:08,063 WARN [config] No Client EndPointIdentificationAlgorithm configured for SslContextFactory@480f6625[provider=null,keyStore=file:///data/XX/config/keystore2,trustStore=file:///etc/ssl/certs/java/cacerts]
2019-02-08 15:07:08,101 INFO [AbstractConnector] Started ServerConnector@124e2ad9{SSL,[ssl, http/1.1]}{0.0.0.0:443}
2019-02-08 15:07:08,101 INFO [Server] Started @820820ms
Мой начальный класс:
public class RunJetty {
public static void main(String[] args) {
if (args.length < 4) {
System.out.println("Insufficient arguments supplied");
usage();
System.exit(1);
}
try {
int port = getPort(args[0]);
File configLocation = getContextLocation(args[1]);
String contextPath = getContextPath(args[2]);
String scheme = args[3];
String resourceBase = args(args, 4, "html");
Server server = new Server();
ServerConnector sslConnector = null;
boolean https = scheme.equals("https");
boolean http = scheme.equals("http");
boolean both = scheme.equals("both");
int sslPort = -1;
if (https || both) {
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion( false );
httpConfig.addCustomizer(new SecureRequestCustomizer());
HttpConnectionFactory httpFactory = new HttpConnectionFactory( httpConfig );
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(System.getProperty("jetty.ssl.keystore"));
sslContextFactory.setKeyStorePassword(System.getProperty("jetty.ssl.keystore.password"));
sslContextFactory.setKeyManagerPassword(System.getProperty("jetty.ssl.key.password"));
sslContextFactory.setTrustStorePath(System.getProperty("jetty.ssl.truststore"));
sslContextFactory.setTrustStorePassword(System.getProperty("jetty.ssl.truststore.password"));
SslConnectionFactory sslFactory = new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
sslConnector = new ServerConnector(server,sslFactory,httpFactory);
sslPort = https ? port : Integer.parseInt(System.getProperty("ssl.port"));
sslConnector.setPort(sslPort);
}
ServerConnector connector = null;
if (http || both) {
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion( false );
if (both) {
httpConfig.setSecurePort(sslPort);
}
HttpConnectionFactory httpFactory = new HttpConnectionFactory( httpConfig );
connector = new ServerConnector( server,httpFactory );
connector.setPort(port);
}
Connector[] connectors = null;
if (both) {
connectors = new Connector[] { connector, sslConnector };
} else if (http) {
connectors = new Connector[] { connector };
} else if (https) {
connectors = new Connector[] { sslConnector };
} else {
throw new IllegalArgumentException("Invalid scheme. Must be 'http', 'https' or 'both'");
}
server.setConnectors(connectors);
HandlerCollection handlers = new HandlerCollection();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(resourceBase);
ContextHandlerCollection contexts = new ContextHandlerCollection();
WebAppContext webAppContext = new WebAppContext(configLocation.getAbsolutePath(), contextPath);
contexts.addHandler(webAppContext);
RequestLogHandler requestLogHandler = new RequestLogHandler();
handlers.setHandlers(new Handler[] { contexts, resourceHandler, new DefaultHandler(), requestLogHandler });
server.setHandler(handlers);
server.setStopAtShutdown(true);
try {
server.start();
server.join();
}
catch (Exception e) {
e.printStackTrace();
}
}
catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
usage();
System.exit(-1);
}
}
static String args(String[] args, int index, String defaultValue) {
if (args.length < index+1) {
return defaultValue;
}
return args[index];
}
static String getContextPath(String arg) {
if (!arg.startsWith("/")) {
arg = "/" + arg;
}
return arg;
}
static File getContextLocation(String arg) {
File file = new File(arg);
if (!file.exists()) {
throw new IllegalArgumentException("Invalid context directory: " + file.getAbsolutePath());
}
return file;
}
static int getPort(String arg) {
int port = 8080;
try {
port = Integer.parseInt(arg);
}
catch (NumberFormatException e1) {
throw new IllegalArgumentException("Invalid port: " + arg);
}
return port;
}
private static void usage() {
System.out.println(RunJetty.class.getName() + " [port] [context directory] [path] [http|https|both]");
}
}