Jetty has always been a highly modular project, which can be assembled in an infinite variety of ways to provide exactly the server/client/container that you required.  With the recent Jetty 9.1 releases, we have added some tools to greatly improve the usability of configuring the modules used by a server.

Jetty now has the concept of a jetty home directory, where the standard distribution is installed, and a jetty base directory, which contains just the configuration of a specific instance of jetty.   With this division, updating to a new version of jetty can be as simple as just updating the reference to jetty home and all the configuration in jetty base will apply.

Defining a jetty home is trivial.  You simply need to unpack the jetty distribution.  For this demonstration, we’ll also define an environment variable:

export JETTY_HOME=/opt/jetty-9.1.3.v20140225/

Creating a jetty base is also easy, as it is just a matter of creating a directory and using the jetty start.jar tools to enable the modules that you want.   For example to create a jetty base with a HTTP and SPDY connector, JMX and a deployment manager (to scan webapps directory), you can do:

mkdir /tmp/demo
cd /tmp/demo
java -jar $JETTY_HOME/start.jar --add-to-startd=http,spdy,jmx,deploy

You now have a jetty base defining a simple server ready to run.  Note that all the required directories have been created and additional dependencies needed for SPDY are downloaded:

demo
├── etc
│   └── keystore
├── lib
│   └── npn
├── start.d
│   ├── deploy.ini
│   ├── http.ini
│   ├── jmx.ini
│   ├── npn.ini
│   ├── server.ini
│   ├── spdy.ini
│   └── ssl.ini
└── webapps

All you need do is copy in your webapp and start the server:

cp ~/somerepo/async-rest.war webapps/java -jar $JETTY_HOME/start.jar

You can see details of the modules available and the current configuration using the commands:

java -jar $JETTY_HOME/start.jar --list-modules
java -jar $JETTY_HOME/start.jar --list-confi

You can see a full demonstration of the jetty base and module capabilities in the following webinar:


Note also that with the Jetty 9.0.4, modules will be available to replace the glassfish versions of JSP and JSTL with the apache release.


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *