Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Upgrading from 8.1.8 to 9.1.0

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
# define the port to use for secure redirection

# Setup a demonstration keystore and truststore

# Set the demonstration passwords.
# Note that OBF passwords are not secure, just protected from casual observation

# Initialize module server

# Initialize module http

# Initialize 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.vm.vendor=Oracle Corporation
 java.vm.version=23.21-b01 HotSpot(TM) 64-Bit Server VM mode SE Runtime Environment

Jetty Environment:

JVM Arguments:
 (no jvm args specified)

System Properties:
 jetty.base = /home/user/my-base
 jetty.home = /home/user/jetty-distribution-9.1.0.RC0

 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 = 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:

# 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}{}

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!

More information on the start.jar in 9.1 can be found at 

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
      (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

The Future Releases of Jetty 9.1:

Now, to followup on what I said about ${jetty.home} and ${jetty.base} ...

Lets say we release Jetty 9.1.0.RC1
You download it and unpack it into /home/user/jetty-distribution-9.1.0.RC1

Then you goto your base directory and just use the distribution, no editing.
[my-base]$ java -jar /home/user/jetty-distribution-9.1.0.RC1/start.jar

If you find some parameterization missing, let us know!

Hope this helps.

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Mon, Oct 7, 2013 at 8:03 AM, John English <john.foreign@xxxxxxxxx> wrote:
I just downloaded 9.1.0.RC0, and did a straight replace of the JARs I use in my existing system. When I tried to start it up I got this error when I try to set up the SSL connector in my etc/jetty.xml:

2013-10-07 16:47:47.129:WARN:oejx.XmlConfiguration:main: Config error at <Call name="addConnector"><Arg>|      <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector"><Set name="Port">8443</Set><Set name="MaxIdleTime">30000</Set><Set name="Acceptors">2</Set><Set name="AcceptQueueSize">100</Set><Set name="Keystore"><Property name="jetty.home" default="."/>/keystore</Set><Set name="Password">checkpoint</Set><Set name="KeyPassword">checkpoint</Set></New>|    </Arg></Call> java.lang.ClassNotFoundException: org.eclipse.jetty.server.ssl.SslSelectChannelConnector in file:/C:/Users/JE/Documents/Projects/Checkpoint/bin/etc/jetty.xml
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jetty.start.Main.invokeMain(
        at org.eclipse.jetty.start.Main.start(
        at org.eclipse.jetty.start.Main.main(
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.ssl.SslSelectChannelConnector
        at$ Source)
        at$ Source)
        at Method)
        at Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.eclipse.jetty.util.Loader.loadClass(
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClass(
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.itemValue(
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.value(
        at org.eclipse.jetty.xml.XmlConfiguration$
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(
        at org.eclipse.jetty.xml.XmlConfiguration.configure(
        at org.eclipse.jetty.xml.XmlConfiguration$
        at Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(
        ... 7 more

The relevant part of jetty.xml is this:

  <Call name="addConnector">
      <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
        <Set name="Port">8443</Set>
        <Set name="MaxIdleTime">30000</Set>
        <Set name="Acceptors">2</Set>
        <Set name="AcceptQueueSize">100</Set>
        <Set name="Keystore"><Property name="jetty.home" default="." />/keystore</Set>
        <Set name="Password">###</Set>
        <Set name="KeyPassword">###</Set>

Obviously many things have changed since 8.1.8. It seems that each major release involves me in a complete rewrite of all my configuration files. I've had to completely replace jetty-jmx.xml with the version from the distro, and also comment out this line in jetty.xml:

  <Set name="GracefulShutdown">1000</Set>

which I can presumably live without (?), but the SSL configuration is a real show stopper. I've looked at the docs, but I'm still baffled. Can anyone please tell me what spell I should incant to placate 9.1.0 instead of the above?

John English
jetty-users mailing list

Back to the top