Faster Jakarta EE Web Application Deployment

The auto discovery features of the Servlet specification can make deployments slow and uncertain.

Auto discovery of Jakarta EE web application configuration can be useful during the development as it allows new features and frameworks to be enabled simply by dropping in a jar file. However, for production deployment, the need to scan the contents of many jars can have a significant impact at startup time.

The ee{8,9,10,11}-quickstart modules allows a Jakarta EE web application to be pre-scanned, making startup predictable and faster. During the pre-scanning all declarative configuration (from web.xml, web-fragment.xml and annotations) are encoded into an effective web.xml, called WEB-INF/quickstart-web.xml, which can be inspected to understand what will be deployed.

Programmatic configuration is not encoded into the generated quickstart-web.xml file.

With the ee{8,9,10,11}-quickstart modules, web applications that took many seconds to scan and deploy can now be deployed in a few hundred milliseconds.

Enabling

You can enable the ee11-quickstart module in this way:

$ cd $JETTY_BASE
$ java -jar $JETTY_HOME/start.jar --add-modules=ee11-quickstart

The $JETTY-BASE/start.d/quickstart.ini file contains these configurable parameters:

jetty.quickstart.mode

The values are:

GENERATE

In this mode, the quickstart-web.xml file are generated and then the Jetty Server is stopped. Use this mode first before changing to either AUTO or QUICKSTART.

AUTO

Allows to deploy the Jakarta EE web application either with or without a quickstart-web.xml file. If the quickstart-web.xml file is present, then it will be used, otherwise the web application is deployed normally.

QUICKSTART

In this mode, if the quickstart-web.xml file is not present, then the web application deployment will fail.

jetty.quickstart.origin

Use this parameter to set the name of the attribute in the quickstart-web.xml file that contains the origin of each element. Knowing the descriptor or annotation from which each element derives can be useful for debugging. Note that the origin attribute does not conform to the web xml schema, so if you deploy with xml validation, you’ll see errors. It is probably best to do a few trial runs with the attribute set, then turn it off for final generation.

jetty.quickstart.xml

Use this parameter to change the name of the generated file. By default this is quickstart-web.xml in the Jakarta EE web application’s WEB-INF directory. The file named by this parameter will always be interpreted relative to the WEB-INF directory.

If your Jakarta EE web application is a *.war file, you will need to either first unpack it yourself, or use a Jetty context XML file (or code equivalent) that calls WebAppContext.setExtractWAR(true). If you allow Jetty to do the unpacking, it will use the usual mechanisms to find the location where to unpack. Note that by default Jetty unpacks to a temporary location which is not reused between executions. You must either specify the directory where to unpack, or make a work directory in your $JETTY_BASE to ensure the unpacked war is preserved and reused across restarts.