Skip to main content
summaryrefslogtreecommitdiffstats
blob: ede1d9aa44b6917e3608a24ac1fa1d83fcf17f21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Deployment Architecture</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="hot-deployment.html" title="Hot Deployment"><link rel="next" href="quickstart-webapp.html" title="Quickstart Webapps"><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.4.1-SNAPSHOT</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">Deployment Architecture</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="hot-deployment.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="quickstart-webapp.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="deployment-architecture"></a>Deployment Architecture</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="deployment-architecture.html#udm-application-providers">Application Providers</a></span></dt><dt><span class="section"><a href="deployment-architecture.html#udm-application-lifecycle-graph">Application LifeCycle Graph</a></span></dt><dt><span class="section"><a href="deployment-architecture.html#udm-lifecycle-bindings">LifeCycle Bindings</a></span></dt><dt><span class="section"><a href="deployment-architecture.html#default-web-app-provider">Understanding the Default WebAppProvider</a></span></dt></dl></div><p>Jetty is built around an extensible Deployment Manager architecture complete with formal LifeCycle for Web Applications going through it.</p><p>For Jetty to serve content (static or dynamic), a <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/handler/ContextHandler.html" target="_top">ContextHandler</a> needs to be configured and added to Jetty in the appropriate location.
A pluggable <code class="literal">DeploymentManager</code> exists to make this process easier.
The Jetty distribution contains example <code class="literal">DeploymentManager</code> configurations to deploy WAR files found in a directory to Jetty, and to deploy Jetty context xml files into Jetty as well.</p><p>The <code class="literal">DeploymentManager</code> is the heart of the typical webapp deployment mechanism; it operates as a combination of an Application LifeCycle Graph, Application Providers that find and provide Applications into the Application LifeCycle Graph, and a set of bindings in the graph that control the deployment process.</p><p><span class="inlinemediaobject"><img src="images/Jetty_DeployManager_DeploymentManager_Roles.png" width="195" alt="image"></span></p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="udm-application-providers"></a>Application Providers</h3></div></div></div><p>Before Jetty deploys an application, an <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/AppProvider.html" target="_top">AppProvider</a> identifies the App and then provides it to the <code class="literal">DeploymentManager</code>.
The main <code class="literal">AppProvider</code> with the Jetty distribution is the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/providers/WebAppProvider.html" target="_top">WebAppProvider.</a></p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="udm-application-lifecycle-graph"></a>Application LifeCycle Graph</h3></div></div></div><p>The core feature of the <code class="literal">DeploymentManager</code> is the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/AppLifeCycle.html" target="_top">Application LifeCycle Graph</a>.</p><p><span class="inlinemediaobject"><img src="images/Jetty_DeployManager_AppLifeCycle-1.png" width="340" alt="image"></span></p><p>The nodes and edges of this graph are pre-defined in Jetty along the most common actions and states found.
These nodes and edges are not hardcoded; they can be adjusted and added to depending on need (for example, any complex requirements for added workflow, approvals, staging, distribution, coordinated deploys for a cluster or cloud, etc.).</p><p>New applications enter this graph at the Undeployed node, and the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/DeploymentManager.html#requestAppGoal(org.eclipse.jetty.deploy.App" target="_top"><code class="literal">java.lang.String DeploymentManager.requestAppGoal(App,String)</code></a> method pushes them through the graph.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="udm-lifecycle-bindings"></a>LifeCycle Bindings</h3></div></div></div><p>A set of default <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/AppLifeCycle.Binding.html" target="_top"><code class="literal">AppLifeCycle.Bindings</code></a> defines standard behavior, and handles deploying, starting, stopping, and undeploying applications.
If desired, custom <code class="literal">AppLifeCycle.Bindings</code> can be written and assigned anywhere on the Application LifeCycle graph.</p><p>Examples of new <code class="literal">AppLifeCycle.Binding</code> implementations that can be developed include:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Validating the incoming application.</li><li class="listitem">Preventing the deployment of known forbidden applications.</li><li class="listitem">Submitting the installation to an application auditing service in a corporate environment.</li><li class="listitem">Distributing the application to other nodes in the cluster or cloud.</li><li class="listitem">Emailing owner/admin of change of state of the application.</li></ul></div><p>There are four default bindings:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardDeployer.html" target="_top">StandardDeployer</a> &#8212; Deploys the ContextHandler into Jetty in the appropriate place.</li><li class="listitem"><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardStarter.html" target="_top">StandardStarter</a> &#8212; Sets the ContextHandler to started and start accepting incoming requests.</li><li class="listitem"><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardStopper.html" target="_top">StandardStopper</a> &#8212; Stops the ContextHandler and stops accepting incoming requests.</li><li class="listitem"><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardUndeployer.html" target="_top">StandardUndeployer</a> &#8212; Removes the ContextHandler from Jetty.</li></ul></div><p><span class="inlinemediaobject"><img src="images/Jetty_DeployManager_DefaultAppLifeCycleBindings.png" width="851" alt="image"></span></p><p>A fifth, non-standard binding, called <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/DebugBinding.html" target="_top">DebugBinding</a>, is also available for debugging reasons; it logs the various transitions through the Application LifeCycle.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="default-web-app-provider"></a>Understanding the Default WebAppProvider</h3></div></div></div><p>The <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/providers/WebAppProvider.html" target="_top">WebAppProvider</a> is used for the deployment of Web Applications packaged as WAR files, expanded as a directory, or declared in a <a class="xref" href="configuring-specific-webapp-deployment.html#deployable-descriptor-file" title="Jetty Deployable Descriptor XML File">Jetty Deployable Descriptor XML File</a>.
It supports hot (re)deployment.</p><p>The basic operation of the <code class="literal">WebAppProvider</code> is to periodically scan a directory for deployables.
In the standard Jetty Distribution, this is configured in the <code class="literal">${jetty.home}/etc/jetty-deploy.xml</code> file.</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"?&gt;
&lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"&gt;
&lt;Configure id="Server" class="org.eclipse.jetty.server.Server"&gt;

  &lt;Call name="addBean"&gt;
    &lt;Arg&gt;
      &lt;New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager"&gt;
        &lt;Set name="contexts"&gt;
          &lt;Ref refid="Contexts" /&gt;
        &lt;/Set&gt;
        &lt;Call id="webappprovider" name="addAppProvider"&gt;
          &lt;Arg&gt;
            &lt;New class="org.eclipse.jetty.deploy.providers.WebAppProvider"&gt;
              &lt;Set name="monitoredDirName"&gt;&lt;Property name="jetty.home" default="." /&gt;/webapps&lt;/Set&gt;
              &lt;Set name="defaultsDescriptor"&gt;&lt;Property name="jetty.home" default="." /&gt;/etc/webdefault.xml&lt;/Set&gt;
              &lt;Set name="scanInterval"&gt;1&lt;/Set&gt;
              &lt;Set name="extractWars"&gt;true&lt;/Set&gt;
            &lt;/New&gt;
          &lt;/Arg&gt;
        &lt;/Call&gt;
      &lt;/New&gt;
    &lt;/Arg&gt;
  &lt;/Call&gt;
&lt;/Configure&gt;</code></pre><p>The above configuration will create a <code class="literal">DeploymentManager</code> tracked as a Server LifeCycle Bean, with the following configuration.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">contexts</span></dt><dd>A passed in reference to the HandlerContainer into which the discovered webapps are deployed.
This is normally a reference that points to the <code class="literal">id="Contexts"</code> found in the <code class="literal">${jetty.home}/etc/jetty.xml</code> file, which itself is an instance of <code class="literal">ContextHandlerCollection</code>.</dd><dt><span class="term">monitoredDirName</span></dt><dd><p class="simpara">The file path or URL to the directory to scan for web applications.</p><pre class="literallayout">Scanning follows these rules:</pre><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">A base directory must exist.</li><li class="listitem">Hidden Files (starting with <code class="literal">"."</code>) are ignored.</li><li class="listitem">Directories with names ending in <code class="literal">".d"</code> are ignored.</li><li class="listitem">Common CVS directories <code class="literal">"CVS"</code> and <code class="literal">"CVSROOT"</code> are ignored.</li><li class="listitem">Any <code class="literal">*.war</code> files are considered <a class="link" href="automatic-webapp-deployment.html" title="Automatic Web Application Deployment">automatic deployables</a>.</li><li class="listitem">Any <code class="literal">*.xml</code> files are considered <a class="link" href="configuring-specific-webapp-deployment.html#deployable-descriptor-file" title="Jetty Deployable Descriptor XML File">context descriptor deployables</a>.</li><li class="listitem">In the special case where both a WAR file and XML file exists for same base name, the XML file is assumed to configure and reference the WAR file (see <a class="xref" href="configuring-specific-webapp-deployment.html" title="Configuring a Specific Web Application Deployment">Configuring a Specific Web Application Deployment</a>).
Since jetty-9.2.7, if either the WAR file or its corresponding XML file changes, the webapp will be redeployed.</li><li class="listitem">A directory is considered to be deployable.</li><li class="listitem">In the special case where both a Directory and WAR file of the same name exists, the WAR file is assumed to be an automatic deployable.</li><li class="listitem">In the special case where both a Directory and XML file of the same name exists, the XML file is assumed to configure and reference the Directory.</li><li class="listitem">All other directories are subject to automatic deployment.</li><li class="listitem">If automatic deployment is used, and the special filename <code class="literal">root.war/ROOT.war</code> or directory name <code class="literal">root/ROOT</code> will result in a deployment to the <code class="literal">"/"</code> context path.</li></ol></div></dd><dt><span class="term">defaultsDescriptor</span></dt><dd>Specifies the default Servlet web descriptor to use for all Web Applications.
The intent of this descriptor is to include common configuration for the Web Application before the Web Application&#8217;s own <code class="literal">/WEB-INF/web.xml</code> is applied.
The <code class="literal">${jetty.home}/etc/webdefault.xml</code> that comes with the Jetty distribution controls the configuration of the JSP and Default servlets, along with MIME-types and other basic metadata.</dd><dt><span class="term">scanInterval</span></dt><dd>The period in seconds between sweeps of the <code class="literal">monitoredDirName</code> for changes: new contexts to deploy, changed contexts to redeploy, or removed contexts to undeploy.</dd><dt><span class="term">extractWars</span></dt><dd>If parameter is true, any packed WAR or zip files are first extracted to a temporary directory before being deployed.
This is advisable if there are uncompiled JSPs in the web apps.</dd><dt><span class="term">parentLoaderPriority</span></dt><dd>Parameter is a boolean that selects whether the standard Java <a class="link" href="jetty-classloading.html" title="Jetty Classloading">parent first delegation</a> is used or the <a class="link" href="jetty-classloading.html" title="Jetty Classloading">servlet specification webapp classloading priority</a>.
The latter is the default.</dd></dl></div></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="hot-deployment.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="quickstart-webapp.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Hot Deployment&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;Quickstart Webapps</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: 2017-01-10)</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>

Back to the top