2009
11.04

Setting up Jetty for Upgrades

Plan for change.

Note: this article refers to Jetty-7

If you set up a lot of Jetty sandboxes, here is a sample structure to make it easy to upgrade to a new version of Jetty without having to reinstall all applications. The trick is to have a number of Jetty sandboxes pointing to a symbolic link, which in turn points to the latest version of Jetty.

Download Jetty

Get latest version of Jetty from http://www.eclipse.org/jetty/downloads.php Check signature. Decompress. Untar.

> cd ...
> tar -xvf jetty-distribution-7.X.X

Now create a symbolic link to this latest version

> ln -s jetty-distribution-7.X.X jetty-7-latest
> chmod a+x jetty-7-latest/bin/*.sh

Create a sandbox

A sandbox refers to a directory where you are testing a web application. Portions of the sandbox are linked back to the latest version of Jetty. Other portions are copied from the latest Jetty. Finally, some portions of the sandbox are original to it.

> mkdir jetty.sandbox
> cd jetty.sandbox
> ln -s ../jetty-7-latest/bin .
> ln -s ../jetty-7-latest/lib .
> ln -s ../jetty-7-latest/start.ini .
> ln -s ../jetty-7-latest/start.jar .
> cp -rp ../jetty-7-latest/etc .
> cp -rp ../jetty-7-latest/resources .
> mkdir contexts
> mkdir logs
> mkdir webapps

At this point, we must configure the sandbox. There are two steps to adding a WAR file:

  1. Copy WAR file to jetty.sandbox/webapps
  2. Create a context file (.xml) located in jetty.sandbox/contexts to enable application. Look at jetty-7-latest/contexts for inspiration.

Finally, start jetty.

> bin/jetty.sh run

Obviously, there is more to configuring and running Jetty. You can get more information by starting at the Jetty Homepage.

Upgrading

When a new version of Jetty becomes available, repeat the first step. Download, verify, decompress and untar the latest version, alongside the first version. Then, change the symbolic link of latest Jetty distribution to the new one.

> cd ...
> tar -xvf jetty-distribution-7.Y.Y
> rm jetty-7-latest
> ln -s jetty-distribution-7.Y.Y jetty-7-latest
> chmod a+x jetty-7-latest/bin/*.sh

Now, all sandboxes are pointing at the latest libraries. Restart all sandboxes.

Unless major changes have occurred in configuration files, this trick should let you upgrade painlessly.

No Comment.

Add Your Comment