Jetty Component


Jetty component provides the functionality of starting a Jetty Server with and without default configurations of listeners, webapplications and servlets. It also provides the feature of dynamically configuring a running Jetty HttpServer with additional listeners, webapplications and servers.

It provides instantiable extensions to the www components, which must also be on the classpath of this component's deployment.

This component has been built against Jetty 4.2.24. It compiles against later versions, but

How to build

First build SmartFrog framework by running ant dist in core/smartfrog

  1. Build the ant tasks by running ant in core/extras/ant

  2. Build Jetty by running ant in core/components/jetty

  3. Step 3 creates one jar file in core/components/jetty/dist/lib. Copy this jar file and the jar files for jetty source from core/components/jetty/lib to core/smartfrog/dist/lib. Other option for adding the jetty jar files is to update class path for the SmartFrog daemon so that jetty classes are available at run time.

Component Description

The Jetty package has different components for jetty server, jetty server with admin privileges, listeners, webapplications, servletcontexts, handlers and servlets.

These are all declared in



Administration component

Attribute Name DescriptionOptional/Mandatory
httpserverHostHost on which the Jetty server configured with admin privileges runsMandatory
listenerPortPort on which the jetty server listensMandatory
contextPathContext Path for the Jetty serverOptional


Attribute NameDescriptionOptional/Mandatory
jettyhomeJetty home path.This is essentially the base directory for operations;Mandatory
serverHostHost on which the Jetty server runsMandatory
enableLoggingBoolean to keep logging on or offMandatory
logPatternpattern for log filesMandatory, but a default is declared
logDirDirectory for log files. If a relative directory path is supplied, it is resolved relative to jettyhome.Default is declared as log/


This component extends CoreJettyServer with extra declarations. It requires a compete


Declare a listener for incoming requests

Attribute NameDescriptionOptional/Mandatory
listenerPortPort on which the listener listensMandatory
serverHostHost on which the listener runsOptional. Omit it bind to all network cards on the host
serverJetty server to which the listener is attachedMandatory

Be aware that setting the serverHost value to "localhost" will bind the server to the loopback address, if there is an entry in the hosttable mapping that name to


Declares a web application

Attribute NameDescriptionOptional/Mandatory
contextPathContext Path for the web applicationMandatory
warFilePath of the web applicationMandatory
resourceIdResource id for the web applicationOptional
serverJetty server to which this web application is attachedMandatory


Attribute NameDescriptionOptional/Mandatory
contextPathContext Path for the servlet contextMandatory
resourceBaseResourcebase for the servlet contextMandatory
serverJetty server to which this servlet context is attached Mandatory
classPathClasspath for the servlet contextOptional

Run-time properties

Attribute NameDescription
ipaddrIP Address of the context (currently determined from the network card/address that the SmartFrog daemon is listening on)
absolutePathBase path of this context


This component is used by different handlers like Dump, Forward, HTAccess etc. for getting added to the ServletContexts. Each handler has specific attributes for its implementation.


The Jetty component can be used for starting different instances of Jetty Server on the same system with and without admin privileges by configuring the attributes defined for each component. A property named jetty.home needs to be set for jetty location on the server before deploying this component.

In a simplest usage the HttpServer component is extended to start a server, by default it is started on port 8080 on the specified host and attached with specified server. For starting another instance of Jetty server, it can be configured for some other port also by configuring the listeners component. Each server instance is added to the ProcessCompond as it is started. This is useful for the dynamic binding feature explained below.

Please go through core/components/jetty/ src/org/smartfrog/services/jetty/example1/2/3.sf for sample usage.

Dynamic binding of listeners, webapplications and servlets to an already running Jetty server can be by giving a reference to a Jetty server to which it should be attached to the components derived from JettyListener , JettyWebApplication and JettyServletContext components. Since all the running Jetty servers have reference in ProcessCompound, the reference to the mentioned server is taken from ProcessCompound and the listeners, webapplications and servletcontexts are added to it.

Please go through core/components/jetty/src/org/smartfrog/services/jetty/dynamicexample.sf for sample usage.