blob: bba67e84ea555fe521e5e6f996644e6888a5dc88 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Quickstart Webapps</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty"><link rel="up" href="configuring-deployment.html" title="Chapter&nbsp;4.&nbsp;Deploying to Jetty"><link rel="prev" href="deployment-architecture.html" title="Deployment Architecture"><link rel="next" href="configuring-contexts.html" title="Chapter&nbsp;5.&nbsp;Configuring Contexts"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><link rel="stylesheet" href="css/highlighter/foundation.css"><script src="js/highlight.pack.js"></script><script>
hljs.initHighlightingOnLoad();
</script><link type="text/css" rel="stylesheet" href="css/font-awesome/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small">
Version: 9.3.27.v20190418</span></td><td style="width: 50%"></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Quickstart Webapps</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="deployment-architecture.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;4.&nbsp;Deploying to Jetty<br><a accesskey="p" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="configuring-contexts.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at
<span class="website">www.webtide.com</span></a></h5><p>
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
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="quickstart-webapp"></a>Quickstart Webapps</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="quickstart-webapp.html#_setting_up_quickstart">Setting up Quickstart</a></span></dt><dt><span class="section"><a href="quickstart-webapp.html#_avoiding_tld_scans_with_precompiled_jsps">Avoiding TLD Scans with precompiled JSPs</a></span></dt><dt><span class="section"><a href="quickstart-webapp.html#_bypassing_start_jar">Bypassing start.jar</a></span></dt></dl></div><p>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.</p><p>With the release of Jetty 9.2, a quickstart module was included which 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 <code class="literal">web.xml</code>, called <code class="literal">WEB-INF/quickstart-web.xml</code>, which can be inspected to understand what will be deployed before deploying.
Not only does the <code class="literal">quickstart-web.xml</code> contain all the discovered Servlets, Filters and Constraints, but it also encodes as context parameters all discovered:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">ServletContainerInitializers</li><li class="listitem">HandlesTypes classes</li><li class="listitem">Taglib Descriptors</li></ul></div><p>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.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_setting_up_quickstart"></a>Setting up Quickstart</h3></div></div></div><p>To use quickstart the module has to be available to the Jetty instance.
In a standard Jetty distribution it can be configured with the following command:</p><div class="screenexample"><pre class="screen">$ java -jar $JETTY_HOME/start.jar --add-to-startd=quickstart</pre></div><p>In a Maven project this is done by adding a dependency on the artifact ID <code class="literal">jetty-quickstart</code>.</p><pre xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><code>&lt;dependency&gt;
&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-quickstart&lt;/artifactId&gt;
&lt;version&gt;9.3.27.v20190418&lt;/version&gt;
&lt;/dependency&gt;</code></pre><p>Additionally, for those using Maven, the <a class="link" href="jetty-maven-plugin.html#get-up-and-running" title="Quick Start: Get Up and Running">Jetty Maven Plugin</a> has a goal, <a class="link" href="jetty-maven-plugin.html#jetty-effective-web-xml" title="jetty:effective-web-xml"><code class="literal">jetty:effective-web-xml</code></a>, which performs quickstart operations.
It should be noted, however, that the Jetty Maven Plugin also includes additional items on it&#8217;s classpath which may not be needed by the webapp.</p><p>Deployed webapps need to be instances of <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.27.v20190418/org/eclipse/jetty/quickstart/QuickStartWebApp.html" target="_top"><code class="literal">org.eclipse.jetty.quickstart.QuickStartWebApp</code></a> rather than the normal <code class="literal">org.eclipse.jetty.webapp.WebAppContext</code>.
If a web application already has a <code class="literal">webapps/myapp.xml</code> file, simply change the class in the <code class="literal">Configure</code> element.
Otherwise, create a <code class="literal">webapps/myapp.xml</code> file as follows:</p><pre xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"&gt;
&lt;Configure class="org.eclipse.jetty.quickstart.QuickStartWebApp"&gt;
&lt;Set name="war"&gt;&lt;Property name="jetty.webapps" default="."/&gt;/benchmark.war&lt;/Set&gt;
&lt;Set name="contextPath"&gt;/benchmark&lt;/Set&gt;
&lt;Set name="autoPreconfigure"&gt;true&lt;/Set&gt;
&lt;/Configure&gt;</code></pre><p>For embedded implementations of Jetty, invoking the <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.27.v20190418/org/eclipse/jetty/quickstart/PreconfigureQuickStartWar.html" target="_top"><code class="literal">org.eclipse.jetty.quickstart.PreconfigureQuickStartWar</code></a> class can be used to configure war files for quickstart deployment.
This will create the <code class="literal">quickstart-web.xml</code> before the first deployment.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_avoiding_tld_scans_with_precompiled_jsps"></a>Avoiding TLD Scans with precompiled JSPs</h3></div></div></div><p>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 <code class="literal">context-param</code> to the <code class="literal">web.xml</code> file (this is done automatically by the Jetty Maven JSPC plugin):</p><pre xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><code>&lt;context-param&gt;
&lt;param-name&gt;org.eclipse.jetty.jsp.precompiled&lt;/param-name&gt;
&lt;param-value&gt;true&lt;/param-value&gt;
&lt;/context-param&gt;</code></pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_bypassing_start_jar"></a>Bypassing start.jar</h3></div></div></div><p>The Jetty <code class="literal">start.jar</code> mechanism is a very powerful and flexible mechanism for constructing a <code class="literal">classpath</code> and executing a configuration encoded in Jetty XML format.
However, this mechanism does take some time to build the <code class="literal">classpath</code>.
The start.jar mechanism can be bypassed by using the <code class="literal">&#8211;dry-run</code> option to generate and reuse a complete command line to start Jetty at a later time:</p><div class="screenexample"><pre class="screen">$ RUN=$(java -jar $JETTY_HOME/start.jar --dry-run)
$ eval $RUN</pre></div><p>Note that <code class="literal">--dry-run</code> 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&#8217;s new persistent location.</p></div></div><script type="text/javascript">
SyntaxHighlighter.all()
</script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="deployment-architecture.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="configuring-deployment.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="configuring-contexts.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Deployment Architecture&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;5.&nbsp;Configuring Contexts</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout">
See an error or something missing?
<span class="callout"><a href="http://github.com/eclipse/jetty.project">Contribute to this documentation at
<span class="website"><i class="fa fa-github" aria-hidden="true"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2019-04-18)</i></span></div></p></body></html>