You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/jetty/modules/operations-guide/pages/deploy/index.adoc
+34-23Lines changed: 34 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,48 +13,57 @@
13
13
14
14
= Web Application Deployment
15
15
16
-
Most of the time you want to be able to customize the deployment of your web applications, for example by changing the `contextPath`, or by adding JNDI entries, or by configuring virtual hosts, etc.
16
+
The Jetty Web Application Deployment mechanism provides for:
17
+
18
+
* the discovery of Web Applications to deploy (e.g. war files, directories or Jetty XML descriptors)
19
+
* determination of default values for key configurations (e.g. contextPath, environment, resource base, temporary directory, etc.)
20
+
* optional extraction of archived resources (e.g. war files and jar files)
21
+
* the discovery of associated configuration files (e.g. properties and XML files) that can be used to customize the deployment (e.g. changing the `contextPath`, or by adding JNDI entries, or by configuring virtual hosts, etc.). The association may be by application or by environment.
22
+
* optional monitoring of all discovered files for hot deployment and/or undeployment.
17
23
18
24
Jetty supports the deployment of each web application to a specific _environment_.
19
25
The available environments are:
20
26
21
-
* Java EE 8 -- Supports Servlet 4.0 (and associated specifications) in the `+javax.*+` packages.
22
-
* Jakarta EE 9 -- Supports Servlet 5.0 (and associated specifications) in the `+jakarta.*+` packages.
23
-
* Jakarta EE 10 -- Supports Servlet 6.0 (and associated specifications) in the `+jakarta.*+` packages.
24
-
* Jetty Core -- Supports web applications written against the Jetty `Handler` APIs, without any Servlet dependencies.
27
+
* Jetty Core -- Supports web applications written against the Jetty `Handler` APIs, without any Servlet dependencies.
28
+
* Java EE 8 -- Supports Servlet 4.0 (and associated specifications) in the `+javax.*+` packages.
29
+
* Jakarta EE 9 -- Supports Servlet 5.0 (and associated specifications) in the `+jakarta.*+` packages.
30
+
* ...
31
+
* Jakarta {ee-current-caps} -- Supports latest Servlet (and associated specifications) in the `+jakarta.*+` packages.
25
32
26
-
This means that you can simultaneously deploy an old Java EE 8 web application, say `old-ee8.war`, alongside a new Jakarta {ee-current-caps} web application, say `new-{ee-current}.war`, alongside a web application that only uses the Jetty `Handler` APIs, say `app-jetty.xml`.
33
+
This means that you can simultaneously deploy an old Java EE 8 web application, say `old-ee8.war`, alongside a new Jakarta {ee-current-caps} web application, say `new-{ee-current}.war`, alongside a web application that only uses the core Jetty `Handler` APIs, say `app-jetty.xml`.
27
34
28
35
The customization of the deployment (for example, web application context path, etc.) is performed by processing <<jetty,Jetty context XML files>>.
29
36
30
-
The `deploy` module contains the `DeploymentManager` component that scans the `$JETTY_BASE/webapps` directory for changes, following the deployment rules described in <<rules,this section>>.
37
+
The `deployment-scanner` module contains the `DeploymentScanner` component that scans the `$JETTY_BASE/webapps` and `$JETTY_BASE/environments` directories for changes, following the deployment rules described in <<rules,this section>>.
31
38
32
-
For each specific environment there is a specific deploy module that you must enable:
39
+
For each specific environment there is a specific deploy module that also must be enabled:
33
40
34
-
* For Java EE 8, xref:modules/standard.adoc#eeN-deploy[`ee8-deploy`]
35
-
* For Java EE 9, xref:modules/standard.adoc#eeN-deploy[`ee9-deploy`]
36
-
* For Java {ee-current-caps}, xref:modules/standard.adoc#eeN-deploy[`{ee-current}-deploy`]
37
-
* For Jetty Core, xref:modules/standard.adoc#core-deploy[`core-deploy`]
41
+
* For Jetty Core, xref:modules/standard.adoc#core-deploy[`core-deploy`]
42
+
* For Java EE 8, xref:modules/standard.adoc#eeN-deploy[`ee8-deploy`]
43
+
* ...
44
+
* For Jakarta {ee-current-caps}, xref:modules/standard.adoc#eeN-deploy[`{ee-current}-deploy`]
38
45
39
46
Each of these modules provide the environment specific features, and depend on the `deploy` module that provides the scanning features.
40
47
48
+
By default, deployment uses the `deployer-standard` module, which provides the `StandardDeployer`, which is used by the scanner to deploy individual Web Applications in a way that allows listeners to be bound to deployment trigger points in a defined deployment lifecycle.
49
+
41
50
[[hot-static]]
42
51
== Hot vs Static Deployment
43
52
44
-
The `DeploymentManager` scans the `$JETTY_BASE/webapps` directory for changes every `N` seconds, where `N` is configured via the `jetty.deploy.scanInterval` property.
53
+
The `DeploymentScanner` scans the `$JETTY_BASE/webapps` and `$JETTY_BASE/environments` directories for changes every `N` seconds, where `N` is configured via the `jetty.deploy.scanInterval` property.
45
54
46
-
By default, the scan interval is `0` seconds, which means _static_ deployment, and the `DeploymentManager` will not scan the `$JETTY_BASE/webapps` directory for changes.
55
+
By default, the scan interval is `0` seconds, which means _static_ deployment, and the `DeploymentScanner` will not scan the `$JETTY_BASE/webapps` directory for changes.
47
56
This means that to deploy/redeploy/undeploy a web application you will need to stop and restart Jetty.
48
57
49
-
Setting the scan interval to a value of `1` second (or greater) means that _hot_ deployment is enabled: if a file is added/changed/removed from the `$JETTY_BASE/webapps` directory, the `DeploymentManager` will notice the change and respectively deploy/redeploy/undeploy the web application.
58
+
Setting the scan interval to a value of `1` second (or greater) means that _hot_ deployment is enabled: if a file is added/changed/removed from the `$JETTY_BASE/webapps` directory, the `DeplymentScanner` will notice the change and respectively deploy/redeploy/undeploy the web application; and if a file is added/changed/removed from the `$JETTY_BASE/environments` directory, the `DeploymentScanner` will deploy/redeploy all web applications in that environment.
50
59
51
60
The following command line enables _hot_ deployment by specifying the `jetty.deploy.scanInterval` property on the command line, and therefore only for this particular run:
To make _hot_ deployment persistent, you need to edit the appropriate `<env>-deploy` module configuration file, `$JETTY_BASE/start.d/<env>-deploy.ini` (eg: `ee11-deploy.ini`), uncomment the module property `jetty.deploy.scanInterval` and change the value to `1` second (or greater):
66
+
To make _hot_ deployment configuration persistent, you need to edit the appropriate `<env>-deploy` module configuration file, `$JETTY_BASE/start.d/<env>-deploy.ini` (eg: `ee11-deploy.ini`), uncomment the module property `jetty.deploy.scanInterval` and change the value to `1` second (or greater):
58
67
59
68
.<env>-deploy.ini
60
69
[source,subs=+quotes]
@@ -67,16 +76,16 @@ To make _hot_ deployment persistent, you need to edit the appropriate `<env>-dep
67
76
[[rules]]
68
77
== Deployment Rules
69
78
70
-
_Adding_ a `+*.war+` file, a `+*.war+` directory, a Jetty context XML file or a normal directory to `$JETTY_BASE/webapps` causes the `DeploymentManager` to deploy the new web application.
79
+
_Adding_ a `+*.war+` file, a `+*.war+` directory, a Jetty context XML file or a normal directory to `$JETTY_BASE/webapps` causes the `DeploymentScanner` to deploy the new web application.
71
80
72
-
_Updating_ a `+*.war+` file or a Jetty context XML file causes the `DeploymentManager` to redeploy the web application, which means that the Jetty context component representing the web application is stopped, then reconfigured, and then restarted.
81
+
_Updating_ a `+*.war+` file or a Jetty context XML file causes the `DeploymentScanner` to redeploy the web application, which means that the Jetty context component representing the web application is stopped, then reconfigured, and then restarted.
73
82
74
-
_Removing_ a `+*.war+` file, a `+*.war+` directory, a Jetty context XML file or a normal directory from `$JETTY_BASE/webapps` causes the `DeploymentManager` to undeploy the web application, which means that the Jetty context component representing the web application is stopped and removed from the Jetty server.
83
+
_Removing_ a `+*.war+` file, a `+*.war+` directory, a Jetty context XML file or a normal directory from `$JETTY_BASE/webapps` causes the `DeploymentScanner` to undeploy the web application, which means that the Jetty context component representing the web application is stopped and removed from the Jetty server.
75
84
76
85
[[rules-context-path]]
77
86
=== Context Path Resolution
78
87
79
-
When a file or directory is added to `$JETTY_BASE/webapps`, the `DeploymentManager` derives the web application `contextPath` from the file or directory name, with the following rules:
88
+
When a file or directory is added to `$JETTY_BASE/webapps`, the `DeploymentScanner` derives the web application `contextPath` from the file or directory name, with the following rules:
80
89
81
90
* If the directory name is, for example, `mywebapp/`, it is deployed as a standard web application if it contains a `WEB-INF/` subdirectory, otherwise it is deployed as a web application of static content.
82
91
The `contextPath` would be `/mywebapp` (that is, the web application is reachable at `+http://localhost:8080/mywebapp/+`).
@@ -130,7 +139,7 @@ This unspecified deployment may not work as the EE 9 web application may use API
130
139
131
140
A Jetty context XML file is a xref:xml/index.adoc[Jetty XML file] that allows you to customize the deployment of web applications.
132
141
133
-
NOTE: Recall that the `DeploymentManager` component of the Jetty `deploy` module <<rules,gives priority>> to Jetty context XML files over `+*.war+` files or directories.
142
+
NOTE: Recall that the `DeploymentScanner` component of the Jetty `deployment-scanner` module <<rules,gives priority>> to Jetty context XML files over `+*.war+` files or directories.
134
143
135
144
To deploy a web application using a Jetty context XML file, simply place the file in the `$JETTY_BASE/webapps` directory.
136
145
@@ -177,7 +186,7 @@ $JETTY_BASE
177
186
178
187
TIP: The `+*.war+` file may be placed anywhere in the file system and does not need to be placed in the `$JETTY_BASE/webapps` directory.
179
188
180
-
IMPORTANT: If you place both the Jetty context XML file _and_ the `+*.war+` file in the `$JETTY_BASE/webapps` directory, remember that they must have the same file name, for example `wiki.xml` and `wiki.war`, so that the `DeploymentManager` deploys the web application only once using the Jetty context XML file (and not the `+*.war+` file).
189
+
IMPORTANT: If you place both the Jetty context XML file _and_ the `+*.war+` file in the `$JETTY_BASE/webapps` directory, remember that they must have the same file name, for example `wiki.xml` and `wiki.war`, so that the `DeploymentScanner` deploys the web application only once using the Jetty context XML file (and not the `+*.war+` file).
181
190
182
191
You can use the features of xref:xml/index.adoc[Jetty XML files] to avoid to hard-code file system paths or other configurations in your Jetty context XML files, for example by using system properties:
183
192
@@ -206,7 +215,7 @@ xref:xml/index.adoc[Jetty context XML file] files can be applied to _all_ webapp
206
215
207
216
Add a properties file to the deployment directory that contains a property naming the location of the xml file to apply.
208
217
The properties file name must be prefixed by the name of the `environment`.
209
-
For example `ee8.properties, ee8-more.propertiesee8-other.properties` would all apply to all contexts deployed in the `ee8` environment.
218
+
For example `$JETTY_BASE/environments/ee8.properties`, `$JETTY_BASE/environments/ee8-more.properties` and `$JETTY_BASE/environments/ee8-other.properties` would all apply to all contexts deployed in the `ee8` environment.
210
219
211
220
If the property file(s) contain one or more properties whose names are prefixed with `org.eclipse.jetty.deploy.environmentXml`, then their values are used as additional context XML files to apply to all contexts deployed in the corresponding environment.
212
221
So for example `org.eclipse.jetty.deploy.environmentXml, org.eclipse.jetty.deploy.environmentXml.more, org.eclipse.jetty.deploy.environmentXml.other` are all acceptable as names.
@@ -219,6 +228,8 @@ The order in which they are applied is determined by _the name of the properties
219
228
220
229
IMPORTANT: The contents of the environment specific context XML file may only contain references to classes appropriate for that environment.
221
230
231
+
The `core-environment`, `ee8-environment`, ..., and `{ee-current}-environment` modules, each create template configuration files for the appropriate environment in the `$JETTY_BASE/environments/` directory.
232
+
222
233
For example, given the previous example of a `$JETTY_BASE/webapps/wiki.xml` and its accompanying `$JETTY_BASE/webapps/wiki.properties` file that declares the `wiki` webapp should be deployed to environment `{ee-current}`, files called `$JETTY_BASE/webapps/{ee-current}.properties` and `$JETTY_BASE/webapps/{ee-current}-feature.properties` can be defined to further configure the webapp.
Deployment is managed via a `DeploymentManager` component that watches a directory for changes.
219
+
Deployment is managed via a `DeploymentScanner` component that watches a directory for changes.
220
220
See xref:deploy/index.adoc[how to deploy web applications] for more information.
221
221
222
-
Adding files or directories to this monitored directory will cause the `DeploymentManager` to deploy them as web applications; updating files already existing in this monitored directory will cause the `DeploymentManager` to re-deploy the corresponding web application; removing files in this monitored directory will cause the `DeploymentManager` to "undeploy" the corresponding web application.
222
+
Adding files or directories to this monitored directory will cause the `DeploymentScanner` to deploy them as web applications; updating files already existing in this monitored directory will cause the `DeploymentScanner` to re-deploy the corresponding web application; removing files in this monitored directory will cause the `DeploymentScanner` to "undeploy" the corresponding web application.
223
223
(You can find a more detailed discussion of these rules in the xref:deploy/index.adoc#rules[deployment rules] section.)
224
224
225
225
Multiple versions of this module exist (`{ee-all}-deploy`) to support each Jakarta EE platform's version of the Java Servlet specification.
@@ -234,7 +234,7 @@ Among the configurable properties, the most relevant are:
234
234
`jetty.deploy.monitoredDir`::
235
235
The name of the monitored directory.
236
236
`jetty.deploy.scanInterval`::
237
-
The scan period in seconds, that is how frequently the `DeploymentManager` wakes up to scan the monitored directory for changes.
237
+
The scan period in seconds, that is how frequently the `DeploymentScanner` wakes up to scan the monitored directory for changes.
238
238
Setting `jetty.deploy.scanInterval=0` disabled _hot_ deployment so that only static deployment will be possible (see also xref:deploy/index.adoc#hot-static[here] for more information).
0 commit comments