private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development
The auto discovery features of the Servlet specification can make deployments slow and uncertain. Auto discovery of Web Application configuration can be useful during the development of a webapp as it allows new features and frameworks to be enabled simply by dropping in a jar file. However, for deployment, the need to scan the contents of many jars can have a significant impact of the start time of a webapp.
From Jetty release 9.2.0.v20140526, the included quickstart module allows a webapp to be pre-scanned and preconfigured.
This means that all the scanning is done prior to deployment and all configuration is encoded into an effective
WEB-INF/quickstart-web.xml, which can be inspected to understand what will be deployed before deploying.
Not only does the
quickstart-web.xml contain all the discovered Servlets, Filters and Constraints, but it also encodes as context parameters all discovered:
With the quickstart mechanism, Jetty is able to entirely bypass all scanning and discovery modes and start a webapp in a predictable and fast way. Tests have shown that webapps that took many seconds to scan and deploy can now be deployed in a few hundred milliseconds.
To use quickstart the module has to be available to the Jetty instance.
In a maven project this is done by adding a dependency on the artifact ID
In a standard Jetty distribution it can be configured with the following command:
$ java -jar $JETTY_HOME/start.jar --add-to-startd=quickstart
Deployed webapps need to be instances of
org.eclipse.jetty.quickstart.QuickStartWebApp rather than the normal
If a web application already has a
webapps/myapp.xml file, simply change the class in the Configure element.
Otherwise, create a
webapps/myapp.xml file as follows:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <Configure class="org.eclipse.jetty.quickstart.QuickStartWebApp"> <Set name="war"><Property name="jetty.webapps" default="."/>/benchmark.war</Set> <Set name="contextPath">/benchmark</Set> <Set name="autoPreconfigure">true</Set> </Configure>
Of course precompiling JSPs is an excellent way to improve the start time of a web application.
As of Jetty 9.2 the Apache Jasper JSP implementation has been used and has been augmented to allow the TLD scan to be skipped.
This can be done by adding a
context-param to the
web.xml file (this is done automatically by the Jetty Maven JSPC plugin):
<context-param> <param-name>org.eclipse.jetty.jsp.precompiled</param-name> <param-value>true</param-value> </context-param>
start.jar mechanism is a very powerful and flexible mechanism for constructing a
classpath and executing a configuration encoded in Jetty XML format.
However, this mechanism does take some time to build the
The start.jar mechanism can be bypassed by using the
–dry-run option to generate and reuse a complete command line to start Jetty at a later time:
$ RUN=$(java -jar $JETTY_HOME/start.jar --dry-run) $ eval $RUN
--dry-run may create a properties file in the temp directory and include it on the generated command line.
If so, then a copy of the temporary properties file should be taken and the command line updated with it’s new persistent location.