JettyPlus://

What it is and how to run it

The purpose of this project is to enrich Jetty by selectively incorporating useful J2EE and non-J2EE features. The result is JettyPlus, an environment offering additional facilities to core web and servlet services, but which does not entail a full-blown application server (such as JettyJBoss and JettyJOnAS).

The feature set currently contains:

How to run it

To use JettyPlus, you must:

How to run it with JMX

As with standard Jetty, you must use an mlet boot file to configure your JettyPlus servers and usually also a JMX http adaptor. An example can be found in extra/etc/jettyplus.mlet.

To run with JMX do:
java -Dstart.class=org.mortbay.util.jmx.Main -Dserver.class=org.mortbay.jetty.plus.Server -Dlog4j.configuration=log4j.xml -jar start.jar extra/etc/jettyplus.mlet

More details

JettyPlus consists of org.mortbay.jetty.plus.jar, ancillary file org.mortbay.jetty.plus.resource.jar, and optionally org.mortbay.jaas.jar as well as a number of libraries found in extra/ext. If you use the convenient start.jar method of running Jetty (highly recommended), all necessary jar files will automatically be placed on the JVM classpath for you. Otherwise, you will need to place the following on the Java classpath in addition to the usual Jetty jars:

The extra/plus/README.TXT file in the source distribution contains more information on the JettyPlus package, including instructions on how to run the JettyPlus demonstration webapps.

Features

Transactions and DataSources

Thanks to the integration of the JOTM and XAPool packages from ObjectWeb, it is now possible to easily incorporate distributed transactional semantics in your servlets and JSPs using javax.transaction.UserTransaction objects.

For example: code to obtain, start and commit a UserTransaction is as follows:

    try
    {
      UserTransaction usertransaction =
                      (UserTransaction)context.lookup("java:comp/UserTransaction");
      //do some stuff
      usertransaction.begin();
      //access some resources and make changes
      usertransaction.commit();
    }
    catch (Exception e)
    {
      usertransaction.rollback();
    }

JettyPlus also provides support for javax.sql.DataSource and javax.sql.XADataSource objects referenced in web.xml <resource-ref> and <resource-env-ref> elements. To use DataSources in your webapp, you need to:

Mail Service

A mail service is provided with JettyPlus. This means that you can send email programmatically from servlets, JSPs etc.

To use the mail service, you need to:

JNDI

JettyPlus supports JNDI, including ENC lookups of <env-entry> tags in the web.xml descriptor. All you need to do to effect JNDI env lookups in your code is to: New:  JettyPlus JNDI service is now lenient on leading and trailing "/" elements of JNDI names. This avoids a lot of errors caused by mis-typings. For example, the following are all now equivalent:
java:comp/env/mything (strictly the correct form according to the spec)
java:/comp/env/mything
java:/comp/env/mything/

Log4J

The JettyPlus package provides a Jetty org.mortbay.util.LogSink to enable Jetty log messages to appear in Log4J style logs. The org.mortbay.jetty.plus.resource.jar file contains a log4j.xml configuration file which may be modified as needed.

To use Log4J:

JAAS

JAAS provides a pluggable framework for authenticating and authorising users. JettyPlus JAAS integrates this with the declarative security model of the Java Servlet Specification.

The Jetty JAAS classes are not included in the main JettyPlus jar (org.mortbay.jetty.plus.jar). Instead, it is built as org.mortbay.jaas.jar to enable it to be used either with standard Jetty, or with JettyPlus.

As JAAS is a pluggable framework, the Jetty JAAS integration aims to dictate as little as possible whilst providing a sufficiently flexible infrastructure to allow users to drop in their own custom LoginModules. An example LoginModule (org.mortbay.jaas.spi.JDBCLoginModule), interacting with a database to store user names, passwords and roles, is included with the release to illustrate what to implement.

Some important classes are:

org.mortbay.jaas.JAASUserRealm

This bridges Jetty's realm concept to JAAS. This class must be configured as the realm for your webapp.

org.mortbay.jaas.JAASPrincipal

Implements the java.security.Principal interface. This class is used by the sample JDBCLoginModule, but the Jetty JAAS infrastructure is Principal agnostic, meaning you can use your own implementation of this class for your LoginModules if you wish.

org.mortbay.jaas.JAASRole

This is a Principal that represents a role possessed by a user.

org.mortbay.jaas.JAASGroup

An implementation of the java.security.acl.Group interface. It is used only by the sample JDBCLoginModule to group all roles possessed by a user under a single Principal called "roles".

org.mortbay.jaas.spi.JDBCLoginModule

An implementation of a LoginModule that uses a database to store user names, passwords and roles. All database-related information is configurable, including:

To use JAAS:

The above describes how to use the Jetty JAAS integration to authenticate web users and authorize them against webapp security constraints. It can also be used for authorization with a Java security manager and permission policy file. For information on how to accomplish this, build and run the JAAS demo in extra/plus as instructed in the README.TXT file in the source distribution.