Merge pull request #587 from WalkerWatch/jetty-9.3.x
Quick start re-work and illustration.
This commit is contained in:
commit
b3eee7884b
|
@ -28,7 +28,7 @@ This can be achieved by:
|
|||
|
||||
* Writing Java code to directly instantiate and assemble Jetty objects. This is referred to as xref:embedding-jetty[].
|
||||
* Using Jetty XML configuration, which is an http://en.wikipedia.org/wiki/Inversion_of_Control[Inversion of Control (IoC)] framework, to instantiate and assemble Jetty objects as XML objects.
|
||||
The `etc/jetty.xml` file is the main Jetty XML configuration file, but there are many other `etc/jetty-`__feature__`.xml` files included in the Jetty distribution.
|
||||
The `etc/jetty.xml` file is the main Jetty XML configuration file, but there are many other `etc/jetty-__feature__.xml` files included in the Jetty distribution.
|
||||
* Using a third party http://en.wikipedia.org/wiki/Inversion_of_Control[IoC] framework like http://en.wikipedia.org/wiki/Spring_Framework[Spring], to instantiate and assemble Jetty objects as Spring beans.
|
||||
|
||||
Because the main Jetty configuration is done by IoC, the link:{JDURL}/[Jetty API documentation] is the ultimate configuration reference.
|
||||
|
@ -37,7 +37,7 @@ Because the main Jetty configuration is done by IoC, the link:{JDURL}/[Jetty API
|
|||
|
||||
The Jetty distribution uses the following configuration files to instantiate, inject and start server via the start.jar mechanism.
|
||||
|
||||
`ini files`::
|
||||
`ini` files::
|
||||
The Jetty Start mechanism uses the command line, the `$JETTY_BASE/start.ini` and/or `$JETTY_BASE/start.d/*.ini` files to create an effective command line of arguments.
|
||||
Arguments may be:
|
||||
|
||||
|
@ -48,14 +48,14 @@ The Jetty distribution uses the following configuration files to instantiate, in
|
|||
* Other start.jar options (see `java -jar start.jar --help`)
|
||||
* Some JVM options in combination with `--exec`, such as `-Xbootclasspath`.
|
||||
+
|
||||
It is the `ini` files located in the Jetty base directory (if different from Jetty home) that are typically edited to change the configuration (e.g. change ports).
|
||||
As of Jetty 9 it is the `ini` files located in the Jetty base directory (if different from Jetty home) that are typically edited to change the configuration (e.g. change ports).
|
||||
|
||||
`mod files`::
|
||||
The `$JETTY_HOME/modules/*.mod` files contain the definition of modules that can be activated by ``--module=name`.
|
||||
`mod` files::
|
||||
The `$JETTY_HOME/modules/*.mod` files contain the definition of modules that can be activated by `--module=name`.
|
||||
Each `mod` file defines:
|
||||
|
||||
* Module dependencies for ordering and activation
|
||||
* The libraries needed by the module to be added to the `classpath`
|
||||
* The libraries needed by the module to be added to the classpath
|
||||
* The XML files needed by the module to be added to the effective command line
|
||||
* Files needed by the activated module
|
||||
* A template `ini` file to be used when activating the `--add-to-start=name` option
|
||||
|
@ -65,10 +65,15 @@ The `*.mod` files are normally located in `$JETTY_HOME/modules/`, but extra or e
|
|||
If module changes are required, it is best practice to copy the particular `*.mod` file from `$JETTY_HOME/modules/` to `$JETTY_BASE/modules/` before being modified.
|
||||
|
||||
XML files::
|
||||
XML files in link:#jetty-xml-syntax[Jetty IoC XML format] or Spring IoC format are listed either on the command line, in `ini` files or are added to the effective command line by a module definition.
|
||||
The XML files instantiate and inject the actual Java objects that comprise the server, connectors and contexts. Because Jetty IoC XML files use properties, most common configuration tasks can be accomplished without editing these XML files and can instead be achieved by editing the property in the corresponding `ini` files.
|
||||
XML files in link:#jetty-xml-syntax[Jetty IoC XML format] or Spring IoC format are listed either on the command line, in `ini` files, or are added to the effective command line by a module definition.
|
||||
The XML files instantiate and inject the actual Java objects that comprise the server, connectors and contexts.
|
||||
Because Jetty IoC XML files use properties, most common configuration tasks can be accomplished without editing these XML files and can instead be achieved by editing the property in the corresponding `ini` files.
|
||||
XML files are normally located in `$JETTY_HOME/etc/`, but extra or edited XML files may be added to `$JETTY_BASE/etc/`.
|
||||
If XML configuration changes are required, it is best practice to copy the XML file from `$JETTY_HOME/etc/` to `$JETTY_BASE/etc/` before being modified.
|
||||
|
||||
Below is an illustration of how the various Jetty configuration files (`ini`, `mod` and XML) are related:
|
||||
|
||||
image:images/Jetty_Configuration_File_Relationships.png[image,width=693]
|
||||
|
||||
==== Other Configuration Files
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
|
@ -25,11 +25,11 @@ However, for most purposes, configuration is a matter of identifying the correct
|
|||
==== Configuring the Server
|
||||
|
||||
The Server instance is the central coordination object of a Jetty server; it provides services and life cycle management for all other Jetty server components.
|
||||
In the standard Jetty distribution, the core server configuration is in `etc/jetty.xml` file, but you can mix in other server configuration which can include:
|
||||
In the standard Jetty distribution, the core server configuration is in `etc/jetty.xml` file, but you can mix in other server configurations which can include:
|
||||
|
||||
ThreadPool::
|
||||
The Server instance provides a ThreadPool instance that is the default Executor service other Jetty server components use.
|
||||
The prime configuration of the thread pool is the maximum and minimum size and is set in `etc/jetty.xml.`
|
||||
The prime configuration of the thread pool is the maximum and minimum size and is set in `start.ini`.
|
||||
Handlers::
|
||||
A Jetty server can have only a single Handler instance to handle incoming HTTP requests.
|
||||
However a handler may be a container or wrapper of other handlers forming a tree of handlers that typically
|
||||
|
@ -42,7 +42,7 @@ Server Attributes::
|
|||
The server holds a generic attribute map of strings to objects so that other Jetty components can associate named objects with the server, and if the value objects implement the LifeCycle interface, they are started and stopped with the server.
|
||||
Typically server attributes hold server-wide default values.
|
||||
Server fields::
|
||||
The server also has some specific configuration fields that you set in ` etc/jetty.xml` for controlling among other things, the sending of dates and versions in HTTP responses.
|
||||
The server also has some specific configuration fields that you set in `start.ini` for controlling among other things, the sending of dates and versions in HTTP responses.
|
||||
Connectors::
|
||||
The server holds a collection of connectors that receive connections for HTTP and the other protocols that Jetty supports.
|
||||
The next section, xref:intro-jetty-configuration-connectors[] describes configuration of the connectors themselves.
|
||||
|
@ -55,7 +55,7 @@ Services::
|
|||
==== Configuring Connectors
|
||||
|
||||
A Jetty Server Connector is a network end point that accepts connections for one or more protocols which produce requests and/or messages for the Jetty server.
|
||||
In the standard Jetty server distribution, several provided configuration files add connectors to the server for various protocols and combinations of protocols: `jetty-http.xml, jetty-https.xml` and `jetty-spdy.xml`.
|
||||
In the standard Jetty server distribution, several provided configuration files add connectors to the server for various protocols and combinations of protocols: `http.ini`, `https.ini` and `jetty-spdy.xml`.
|
||||
The configuration needed for connectors is typically:
|
||||
|
||||
Port::
|
||||
|
@ -101,8 +101,8 @@ Configuration values that are common to all contexts are:
|
|||
|
||||
contextPath::
|
||||
The contextPath is a URL prefix that identifies which context a HTTP request is destined for.
|
||||
For example, if a context has a context path `/foo`, it handles requests to ` /foo`, `/foo/index.html`,
|
||||
`/foo/bar/`, and `/foo/bar/image.png` but it does not handle requests like `/`, ` /other/`, or `/favicon.ico`.
|
||||
For example, if a context has a context path `/foo`, it handles requests to `/foo`, `/foo/index.html`,
|
||||
`/foo/bar/`, and `/foo/bar/image.png` but it does not handle requests like `/`, `/other/`, or `/favicon.ico`.
|
||||
A context with a context path of / is called the root context.
|
||||
+
|
||||
The context path can be set by default from the deployer (which uses the filename as the basis for the context path); or in code; or it can be set by a Jetty IoC XML that is either applied by the deployer or found in the `WEB-INF/jetty-web.xml` file of a standard web app context.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
To start Jetty on the default port of 8080, run the following command:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> cd $JETTY_HOME
|
||||
> java -jar start.jar
|
||||
2015-06-04 10:50:44.806:INFO::main: Logging initialized @334ms
|
||||
|
@ -29,7 +29,7 @@ To start Jetty on the default port of 8080, run the following command:
|
|||
2015-06-04 10:50:45.012:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///opt/jetty-distribution-9.3.0.v20150601/webapps/] at interval 1
|
||||
2015-06-04 10:50:45.030:INFO:oejs.ServerConnector:main: Started ServerConnector@19dfb72a{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
|
||||
2015-06-04 10:50:45.030:INFO:oejs.Server:main: Started @558ms
|
||||
....
|
||||
----
|
||||
|
||||
You can point a browser at this server at link:http://localhost:8080[].
|
||||
However, as there are no webapps deployed in the $JETTY_HOME directory, you will see a 404 error page served by Jetty.
|
||||
|
@ -42,7 +42,7 @@ Instead, see how to link:#creating-jetty-base[create a Jetty Base] below.
|
|||
Within the standard jetty distribution there is the `demo-base` directory, which demonstrates the recommended way to run Jetty in a directory separately from $JETTY_HOME:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> cd $JETTY_HOME/demo-base/
|
||||
> java -jar $JETTY_HOME/start.jar
|
||||
2015-06-04 10:55:24.161:INFO::main: Logging initialized @308ms
|
||||
|
@ -66,7 +66,7 @@ Within the standard jetty distribution there is the `demo-base` directory, which
|
|||
2015-06-04 10:55:26.259:INFO:oejus.SslContextFactory:main: x509={jetty.eclipse.org=jetty} wild={} alias=null for SslContextFactory@23941fb4(file:///opt/jetty-distribution-9.3.0.v20150601/demo-base/etc/keystore,file:///opt/jetty-distribution-9.3.0.v20150601/demo-base/etc/keystore)
|
||||
2015-06-04 10:55:26.269:INFO:oejs.ServerConnector:main: Started ServerConnector@5d908d47{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
|
||||
2015-06-04 10:55:26.270:INFO:oejs.Server:main: Started @2417ms
|
||||
....
|
||||
----
|
||||
|
||||
You can see this demo server by pointing a browser at link:http://localhost:8080[], will now show a welcome page and several demo/test web applications.
|
||||
|
||||
|
@ -78,13 +78,13 @@ ____
|
|||
You can see the configuration of the demo-base by using the following commands:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> cd $JETTY_HOME/demo-base/
|
||||
> java -jar $JETTY_HOME/start.jar --list-modules
|
||||
...
|
||||
> java -jar %JETTY_HOME/start.jar --list-config
|
||||
...
|
||||
....
|
||||
----
|
||||
|
||||
[[creating-jetty-base]]
|
||||
==== Creating a new Jetty Base
|
||||
|
@ -101,15 +101,15 @@ jetty.base::
|
|||
The `jetty.home` and `jetty.base` properties may be explicitly set on the command line, or they can be inferred from the environment if used with commands like:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> cd $JETTY_BASE
|
||||
> java -jar $JETTY_HOME/start.jar
|
||||
....
|
||||
----
|
||||
|
||||
The following commands: create a new base directory; enables a HTTP connector and the web application deployer; copies a demo webapp to be deployed:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> JETTY_BASE=/tmp/mybase
|
||||
> mkdir $JETTY_BASE
|
||||
> cd $JETTY_BASE
|
||||
|
@ -138,7 +138,7 @@ INFO: Base directory was modified
|
|||
2015-06-04 11:10:16.628:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@1a407d53{/,[file:///tmp/jetty-0.0.0.0-8080-ROOT.war-_-any-4510228025526425427.dir/webapp/, jar:file:///tmp/jetty-0.0.0.0-8080-ROOT.war-_-any-4510228025526425427.dir/webapp/WEB-INF/lib/example-async-rest-jar-9.3.0.v20150601.jar!/META-INF/resources],AVAILABLE}{/ROOT.war}
|
||||
2015-06-04 11:10:16.645:INFO:oejs.ServerConnector:main: Started ServerConnector@3abbfa04{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
|
||||
2015-06-04 11:10:16.646:INFO:oejs.Server:main: Started @634ms
|
||||
....
|
||||
----
|
||||
|
||||
[[quickstart-changing-jetty-port]]
|
||||
==== Changing the Jetty Port
|
||||
|
@ -146,11 +146,11 @@ INFO: Base directory was modified
|
|||
You can configure Jetty to run on a different port by setting the `jetty.http.port` Property on the command line:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> cd $JETTY_BASE
|
||||
> java -jar $JETTY_HOME/start.jar jetty.http.port=8081
|
||||
...
|
||||
....
|
||||
----
|
||||
|
||||
Alternatively, property values can be added to the effective command line built from either the `start.ini` file or `start.d/http.ini` files.
|
||||
By default, the jetty distribution defines the jetty.http.port property in the `start.d/http.ini` file, which may be edited to set another value.
|
||||
|
@ -174,14 +174,14 @@ ____
|
|||
To add the HTTPS connector to a jetty configuration, the https module can be activated by the following command:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> java -jar $JETTY_HOME/start.jar --add-to-startd=https,http2
|
||||
[...]
|
||||
> java -jar $JETTY_HOME/start.jar
|
||||
[...]
|
||||
2015-06-04 13:52:01.933:INFO:oejs.ServerConnector:main: Started ServerConnector@6f1fba17{SSL,[ssl, alpn, h2, http/1.1]}{0.0.0.0:8443}
|
||||
[...]
|
||||
....
|
||||
----
|
||||
|
||||
The --add-to-startd command sets up the effective command line in the ini files to run an ssl connection that supports the HTTPS and HTTP2 protocols as follows:
|
||||
|
||||
|
@ -202,10 +202,10 @@ ____
|
|||
You can configure the SSL connector to run on a different port by setting the `jetty.ssl.port` property on the command line:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> cd $JETTY_BASE
|
||||
> java -jar $JETTY_HOME/start.jar jetty.ssl.port=8444
|
||||
....
|
||||
----
|
||||
|
||||
Alternatively, property values can be added to the effective command line built from the `start.ini` file and `start.d/*.ini` files.
|
||||
If you used the --add-to-startd command to enable https, then you can edit this property in the `start.d/https.ini` file.
|
||||
|
@ -217,6 +217,6 @@ The job of the `start.jar` is to interpret the command line, `start.ini` and `st
|
|||
The `start.jar` mechanism has many options which are documented in the xref:startup[] administration section and you can see them in summary by using the command:
|
||||
|
||||
[source, screen]
|
||||
....
|
||||
----
|
||||
> java -jar $JETTY_HOME/start.jar --help
|
||||
....
|
||||
----
|
||||
|
|
|
@ -231,7 +231,6 @@ xmlns:date="http://exslt.org/dates-and-times"
|
|||
<xsl:element name="pre">
|
||||
<xsl:attribute name="class">screen</xsl:attribute>
|
||||
<xsl:value-of select="text()"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
|
|
Loading…
Reference in New Issue