Skip to main content
Jump to: navigation, search

Jetty/Tutorial/Jetty-OSGi SDK


Jetty-OSGi SDK extends the Plugin Development Environment (PDE) to support the debugging of web-applications.

The "Jetty" launch configuration prepares the execution of jetty-osgi and deploys web-applications on it. The web-applications are either defined as pure java projects or as OSGi bundles. The SDK also provides two project templates suitable to create web-applications embedded inside an OSGi bundle.


The build of the SDK is not yet done in eclipse.

Download eclipse-3.6M3 or more recent. Download the latest jetty-SDK-runtime and jetty-SDK-sources

Unzip those inside the dropins folder of your eclipse-3.6M3 installation. Make sure that inside the dropins folder it looks like this: ${eclipse.pde.home}/dropins/eclipse/features Otherwise the features and plugins inside dropins will be ignored.

First web-application defined in an OSGi bundle (RFC66)

Create a new OSGi Project

Create a new Plug-in Project

OSGi Project name

Choose 'OSGi bundle'

OSGi Project parameters

Choose 'Next' instead of 'Finish' to show the project templates.

OSGi Project RFC66 template

Choose the 'Jetty RFC66' template.

Web-application parameters

The web-bundle generated.

Right-click and choose run as...

Right-click on the project and choose "Run as... Jetty-on-OSGi"

Open a web-browser and check.

Open a web-browser and check that the webapp is running. Everything is configured by default at this point: jetty is running on localhost at port 8080.

Launch configuration

Run Configuration.

To customize the configuration of jetty used to run this web-application, choose the menu "Run configuration..." and select the "Launch Jetty in OSGi" node. The first tab "Jetty Configuration" points to the default jetty.home folder. Jetty-on-OSGi uses a folder hierarchy inside which it locates the configuration file(s) (${jetty.home}/etc/jetty.xml), the configuration for the central logging (${jetty.home}/resources/logback.xml). By default the SDK will generate the jetty.home folder in the PDE runtime workspace and will place the default configuration files identical to the ones distributed with jetty.

The wizard gives direct access to jetty.xml but other settings should be done by accessing the file system. (TODO: improve; for example provide a wizard to import as a project a jetty configuration so that everything can be done from eclipse.)

Debugging web-applications defined in standard java projects

CAS a java project

A very common situation is to have a set of existing java projects that define a web-application. The SDK is able to deploy them and execute them just like an RFC66 web-bundle.

Let's take a java project that defines a web-application: it contains a folder 'webapp' inside which jsp pages and WEB-INF/web.xml are located.

Jetty-OSGi won't run this as an OSGi bundle: it depends on a set of jars that are outside of the platform and eventually on other java projects.

Jetty-OSGi only needs to recognize the webapp folder and to know what is the servlet context to use. The current approach consists of adding a META-INF/MANIFEST.MF file to the project and to use the headers that jetty-osgi would use for an OSGi web-application:

Web-ContextPath: /cas
will set the context path to "/cas"
Jetty-WarFolderPath: /src/main/webapp

In fact by default Jetty-WarFolderPath is assumed to be '/src/main/webapp' and the context path is the name of the eclipse project.

It would be nice to support more sophisticated ways of identifying a java project that contains a web-application: WTP and maven's pom.xml file come to mind.

Choose the java projects to deploy as webapps

When there are java projects that are not OSGi projects, the Jetty Configuration tab shows them in a list. TODO: a better UI that actually tells the user if a java-project is correctly identified as a webapp or not.

TODO: more doc. Although the java project is not an OSGi project, it is possible to inject OSGi dependencies: Use the Require-Bundle or the Import-Package in the manifest and add to the .classpath the line:

<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>

This is very useful to gradually migrate java projects to OSGi bundles: not all libraries need to be OSGi ready. Partially migrated libs are fine during development.

Developing Jetty-OSGi in PDE

Use the jetty-sdk setup; identical to the one used for the development of web-applications. Import as project the bundles to work on: [1]

Start hacking using the PDE just like any other OSGi bundle or eclipse plugin. Launch using the jetty configuration. The PDE will use the bundles as defined in the workspace as a replacement for the jetty bundles.

Additional Resources

Jetty-OSGi, RFC66, PDE We are working on migrating all building an update site and executing the build on eclipse with the rest of the jetty@eclipse project. In the mean time, the latest code is here: [

Back to the top