With Jetty 9.1 and onwards, here's what you'll do ...
We'll use the ${jetty.home} and ${jetty.base} concepts to their maximum effect.
Example is assuming you have jetty-distribution unpacked in /home/user/jetty-distribution-9.1.0.RC0
Create a base directory, anywhere.
[/home/user]$ mkdir my-base
[/home/user]$ cd my-base
# now add the modules for ssl + http + webapp deployment
[my-base]$ java -jar /home/user/jetty-distribution-9.1.0.RC0/start.jar --add-to-start=ssl,http,deploy
ssl initialised in ${jetty.base}/start.ini (appended)
ssl enabled in ${jetty.base}/start.ini
server initialised in ${jetty.base}/start.ini (appended)
server enabled in ${jetty.base}/start.ini
http initialised in ${jetty.base}/start.ini (appended)
http enabled in ${jetty.base}/start.ini
server enabled in ${jetty.base}/start.ini
deploy initialised in ${jetty.base}/start.ini (appended)
deploy enabled in ${jetty.base}/start.ini
MKDIR: ${jetty.base}/webapps
server enabled in ${jetty.base}/start.ini
# Look at your directory
[my-base]$ ls -la
total 20
drwxrwxr-x 4 user group 4096 Oct 8 06:55 ./
drwxr-xr-x 103 user group 4096 Oct 8 06:53 ../
drwxrwxr-x 2 user group 4096 Oct 8 06:55 etc/
-rw-rw-r-- 1 user group 815 Oct 8 06:55 start.ini
drwxrwxr-x 2 user group 4096 Oct 8 06:55 webapps/
# Copy your war files into webapps
[my-base]$ cp ~/code/project/target/gadget.war webapps/
# Copy your keystore into place
[my-base]$ cp ~/code/project/keystore etc/keystore
# Edit the start.ini to setup your SSL settings.
[my-base]$ cat start.ini
#
# Initialize module ssl
#
--module=ssl
# define the port to use for secure redirection
jetty.secure.port=8443
# Setup a demonstration keystore and truststore
jetty.keystore=etc/keystore
jetty.truststore=etc/keystore
# Set the demonstration passwords.
# Note that OBF passwords are not secure, just protected from casual observation
jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g
jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
#
# Initialize module server
#
--module=server
threads.min=10
threads.max=200
threads.timeout=60000
jetty.dump.start=false
jetty.dump.stop=false
#
# Initialize module http
#
--module=http
jetty.port=8080
http.timeout=30000
#
# Initialize module deploy
#
--module=deploy
# now lets look at the configuration you have at this point.
[my-base]$ java -jar /home/user/jetty-distribution-9.1.0.RC0/start.jar --list-config
Java Environment:
-----------------
java.home=/home/user/java/jdk-7u21-x64/jre
java.vm.vendor=Oracle Corporation
java.vm.version=23.21-b01
java.runtime.version=1.7.0_21-b11
java.io.tmpdir=/tmp
Jetty Environment:
-----------------
jetty.home=/home/user/jetty-distribution-9.1.0.RC0
jetty.base=/home/user/my-base
jetty.version=9.1.0.RC0
JVM Arguments:
--------------
(no jvm args specified)
System Properties:
------------------
jetty.base = /home/user/my-base
jetty.home = /home/user/jetty-distribution-9.1.0.RC0
Properties:
-----------
http.timeout = 30000
jetty.dump.start = false
jetty.dump.stop = false
jetty.keymanager.password = OBF:1u2u1wml1z7s1z7a1wnl1u2g
jetty.keystore = etc/keystore
jetty.keystore.password = OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
jetty.port = 8080
jetty.secure.port = 8443
jetty.truststore = etc/keystore
jetty.truststore.password = OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
threads.max = 200
threads.min = 10
threads.timeout = 60000
Jetty Server Classpath:
-----------------------
Version Information on 11 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
changes to the --module=name command line options will be reflected here.
0: 3.1.0 | ${jetty.home}/lib/servlet-api-3.1.jar
1: 3.1.RC0 | ${jetty.home}/lib/jetty-schemas-3.1.jar
2: 9.1.0.RC0 | ${jetty.home}/lib/jetty-http-9.1.0.RC0.jar
3: 9.1.0.RC0 | ${jetty.home}/lib/jetty-continuation-9.1.0.RC0.jar
4: 9.1.0.RC0 | ${jetty.home}/lib/jetty-server-9.1.0.RC0.jar
5: 9.1.0.RC0 | ${jetty.home}/lib/jetty-xml-9.1.0.RC0.jar
6: 9.1.0.RC0 | ${jetty.home}/lib/jetty-util-9.1.0.RC0.jar
7: 9.1.0.RC0 | ${jetty.home}/lib/jetty-io-9.1.0.RC0.jar
8: 9.1.0.RC0 | ${jetty.home}/lib/jetty-servlet-9.1.0.RC0.jar
9: 9.1.0.RC0 | ${jetty.home}/lib/jetty-webapp-9.1.0.RC0.jar
10: 9.1.0.RC0 | ${jetty.home}/lib/jetty-deploy-9.1.0.RC0.jar
Jetty Active XMLs:
------------------
${jetty.home}/etc/jetty.xml
${jetty.home}/etc/jetty-http.xml
${jetty.home}/etc/jetty-ssl.xml
${jetty.home}/etc/jetty-deploy.xml
# now lets start Jetty
[my-base]$ java -jar /home/user/jetty-distribution-9.1.0.RC0/start.jar
2013-10-08 07:06:55.837:INFO:oejs.Server:main: jetty-9.1.0.RC0
2013-10-08 07:06:55.853:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/home/joakim/my-base/webapps/] at interval 1
2013-10-08 07:06:55.872:INFO:oejs.ServerConnector:main: Started ServerConnector@72974691{HTTP/1.1}{0.0.0.0:8080}
What's going on here?
Well, for starters, we've introduced a separation of ${jetty.base} and ${jetty.home}.
${jetty.home} is where your distribution lies, unchanged, unedited.
${jetty.base} is where your customizations are.
More on how this helps in a bit.
Next, you'll see that we have --module=<name> here and there, that's because we've wrapped up the goal of a module (libs, configuration xmls, and properties) into a single unit, with dependencies on other modules.
You can see the list of modules this way.
[my-base]$ java -jar /home/user/jetty-distribution-9.1.0.RC0/start.jar --list-modules
Jetty All Available Modules:
----------------------------
Module: annotations
LIB: lib/jetty-annotations-${jetty.version}.jar
LIB: lib/annotations/*.jar
XML: etc/jetty-annotations.xml
depends: [plus]
Module: client
LIB: lib/jetty-client-${jetty.version}.jar
depends: []
Module: debug
XML: etc/jetty-debug.xml
depends: [server]
Module: deploy
LIB: lib/jetty-deploy-${jetty.version}.jar
XML: etc/jetty-deploy.xml
depends: [webapp]
enabled: ${jetty.base}/start.ini
Module: ext
LIB: lib/ext/*.jar
depends: []
Module: http
XML: etc/jetty-http.xml
depends: [server]
enabled: ${jetty.base}/start.ini
Module: https
XML: etc/jetty-https.xml
depends: [ssl]
Module: ipaccess
XML: etc/jetty-ipaccess.xml
depends: [server]
Module: jaas
LIB: lib/jetty-jaas-${jetty.version}.jar
XML: etc/jetty-jaas.xml
depends: [server]
Module: jaspi
LIB: lib/jetty-jaspi-${jetty.version}.jar
LIB: lib/jaspi/*.jar
depends: [security]
Module: jmx
LIB: lib/jetty-jmx-${jetty.version}.jar
XML: etc/jetty-jmx.xml
depends: []
Module: jndi
LIB: lib/jetty-jndi-${jetty.version}.jar
LIB: lib/jndi/*.jar
depends: [server]
Module: jsp
LIB: lib/jsp/*.jar
depends: [servlet]
Module: jvm
depends: []
Module: logging
XML: etc/jetty-logging.xml
depends: []
Module: lowresources
XML: etc/jetty-lowresources.xml
depends: [server]
Module: monitor
LIB: lib/jetty-monitor-${jetty.version}.jar
XML: etc/jetty-monitor.xml
depends: [client, server]
Module: npn
depends: []
Module: plus
LIB: lib/jetty-plus-${jetty.version}.jar
XML: etc/jetty-plus.xml
depends: [server, security, jndi]
Module: proxy
LIB: lib/jetty-proxy-${jetty.version}.jar
XML: etc/jetty-proxy.xml
depends: [client, server]
Module: requestlog
XML: etc/jetty-requestlog.xml
depends: [server]
Module: resources
LIB: resources
depends: []
Module: rewrite
LIB: lib/jetty-rewrite-${jetty.version}.jar
XML: etc/jetty-rewrite.xml
depends: [server]
Module: security
LIB: lib/jetty-security-${jetty.version}.jar
depends: [server]
Module: server
LIB: lib/servlet-api-3.1.jar
LIB: lib/jetty-schemas-3.1.jar
LIB: lib/jetty-http-${jetty.version}.jar
LIB: lib/jetty-continuation-${jetty.version}.jar
LIB: lib/jetty-server-${jetty.version}.jar
LIB: lib/jetty-xml-${jetty.version}.jar
LIB: lib/jetty-util-${jetty.version}.jar
LIB: lib/jetty-io-${jetty.version}.jar
XML: etc/jetty.xml
depends: []
enabled: ${jetty.base}/start.ini
Module: servlet
LIB: lib/jetty-servlet-${jetty.version}.jar
depends: [server]
Module: servlets
LIB: lib/jetty-servlets-${jetty.version}.jar
depends: [servlet]
Module: setuid
LIB: lib/setuid/jetty-setuid-java-1.0.1.jar
XML: etc/jetty-setuid.xml
depends: [server]
Module: spdy
LIB: lib/spdy/*.jar
XML: etc/jetty-ssl.xml
XML: etc/jetty-spdy.xml
depends: [ssl, npn]
Module: ssl
XML: etc/jetty-ssl.xml
depends: [server]
enabled: ${jetty.base}/start.ini
Module: stats
XML: etc/jetty-stats.xml
depends: [server]
Module: webapp
LIB: lib/jetty-webapp-${jetty.version}.jar
depends: [servlet]
Module: websocket
LIB: lib/websocket/*.jar
depends: [annotations]
Module: xinetd
XML: etc/jetty-xinetd.xml
depends: [server]
Jetty Active Module Tree:
-------------------------
+ Module: server [enabled]
+ Module: http [enabled]
+ Module: servlet [transitive]
+ Module: ssl [enabled]
+ Module: webapp [transitive]
+ Module: deploy [enabled]
This shows you the modules, by name, what libraries they bring in, and what xml configurations they will use, what other module they depend on (even optional ones), and if the module is in use, where it was enabled from.
Next, we've been taking time to parameterize all of our standard configuration xmls.
In the example above, you'll see that all of the SSL parameters are now just properties in the start.ini, reducing to eliminating the need to be editing XML files.
Lastly, know that anything you see in ${jetty.home} can also be overridden in ${jetty.base}, even xml configurations and libraries!
Here's an excerpt:
What happens when you execute start.jar:
- load and parse all INIs found in ${jetty.base}/start.d/*.ini as command line arguments
- load and parse ${jetty.base}/start.ini as command line arguments
- parse actual command line arguments used to execute start.jar itself
- resolve any xml configuration files, modules, and libraries using base vs home resolution steps
- check if file exists as relative reference to ${jetty.base}
- check if file exists as relative reference to ${jetty.home}
- use default behavior of java.io.File
(Relative to System.getProperty("user.dir") and then as absolute file system path)
- load any dependant modules. (merge xml, library, and properties results with active command line)
- build out server classpath
- determine run mode:
- show informational command line options, and exit
- execute jetty normally, wait for jetty to stop
- execute a forked jvm to run jetty in, wait for forked jvm to exit
- If jetty is to be started:
- load each xml configuration (in the order determined by the inis and module system)
- let xml configuration start jetty
Now, to followup on what I said about ${jetty.home} and ${jetty.base} ...
Hope this helps.