blob: 9c64c715ccf2d9740b578e28ec089bceb7ac2761 [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-NS Stylesheets V1.76.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 : The Definitive Reference"><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="overlay-deployer.html" title="Overlay WebApp Deployer"><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"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/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.0.v20150612</span></td><td style="width: 50%"><script type="text/javascript"> (function() {
var cx = '016459005284625897022:obd4lsai2ds';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script><gcse:search></gcse:search></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="icon-chevron-left"></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="icon-home"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="overlay-deployer.html">Next <i class="icon-chevron-right"></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 from 1 day to full product delivery
</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><dt><span class="section"><a href="quickstart-webapp.html#d0e2982">Setting up Quickstart</a></span></dt><dt><span class="section"><a href="quickstart-webapp.html#d0e3006">Preconfiguring the web application</a></span></dt><dt><span class="section"><a href="quickstart-webapp.html#d0e3035">Avoiding TLD Scans with precompiled JSPs</a></span></dt><dt><span class="section"><a href="quickstart-webapp.html#d0e3045">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>From Jetty release 9.2.0.v20140526, we have included the quickstart
module that 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="filename">web.xml</code>, called
<code class="filename">WEB-INF/quickstart-web.xml</code>, 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:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>ServletContainerInitializers</p></li><li class="listitem"><p>HandlesTypes classes</p></li><li class="listitem"><p>Taglib Descriptors</p></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="d0e2982"></a>Setting up Quickstart</h3></div></div></div><p>To use quickstart the module has to be available to your jetty
instance. In a maven project this is done just by adding a dependency on
the artifact ID jetty-quickstart or with a standard jetty distribution you
can run the command:</p><div class="screenexample"><pre class="screen">$ java -jar $JETTY_HOME/start.jar --add-to-startd=quickstart</pre></div><p>Also the webapps you deploy need to be instances of <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/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 your web
application already has a <code class="filename">webapps/myapp.xml</code> file,
then you can simply change the class in the Configure element, otherwise
you can create an <code class="filename">webapps/myapp.xml</code> file as
follows:</p><script type="syntaxhighlighter" class="brush: plain;toolbar: false">
<![CDATA[<?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>]]>
</script></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3006"></a>Preconfiguring the web application</h3></div></div></div><p>If the QuickStateWebApp method setAutoPreconfigure(true) is called
(see example in myapp.xml above), then the first time the webapp is
deployed a <code class="filename">WEB-INF/quickstart-web.xml</code> file will be
generated that contains the effective <code class="filename">web.xml</code> for all
the discovered configuration. On subsequent deployments, all the discovery
steps are skipped and the <code class="filename">quickstart-web.xml</code> is used
directly to configure the web Application.</p><p>It is also possible to preconfigure a war file manually by running
the class <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/quickstart/PreconfigureQuickStartWar.html" target="_top">org.eclipse.jetty.quickstart.PreconfigureQuickStartWar</a>
simply with the jetty-all-uber (aggregate) jar:</p><div class="screenexample"><pre class="screen">$ java -cp jetty-all-9.3.0.v20150612-uber.jar org.eclipse.jetty.quickstart.PreconfigureQuickStartWar myapp.war</pre></div><p>This will create the <code class="filename">quickstart-web.xml</code> file
before the first deployment. Note that this can also be a good debugging
tool for discovered configuration and if run with debug turned on the
origin of every element is included in the
<code class="filename">quickstart-web.xml</code> file. Run the class with no
arguments to see other options for running it.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3035"></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. Since jetty 9.2.0, 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
<code class="filename">web.xml</code> file (this is done automatically by the Jetty
Maven JSPC plugin):</p><script type="syntaxhighlighter" class="brush: plain;toolbar: false">
<![CDATA[<context-param>
<param-name>org.eclipse.jetty.jsp.precompiled</param-name>
<param-value>true</param-value>
</context-param>]]>
</script></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d0e3045"></a>Bypassing start.jar</h3></div></div></div><p>The jetty 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 classpath. The start.jar mechanism can be bypassed by using
the <span class="command"><strong>&#8211;dry-run</strong></span> 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 <span class="command"><strong>--dry-run</strong></span> 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.</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="icon-chevron-left"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="configuring-deployment.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="overlay-deployer.html">Next <i class="icon-chevron-right"></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="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;Overlay WebApp Deployer</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/jetty-project/jetty-documentation">Contribute to this documentation at
<span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2015-06-15T13:18:15-05:00)</i></span></div></p><script 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" type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1149868-7']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></body></html>