Tutorial Using OSGi enRoute with Maven

Maven Eval Tutorial

This tutorial shows you how to build an OSGi enRoute executable JAR using Maven and vi only. This tutorial will be purely command-line based. (There is one section outlining how M2E and the Bndtools editors can be useful, even for pure command line aficionados.)

What we will build is a similar application that is developed in the Base Tutorial but instead of Bndtools we use Maven.

This application is a trivial Web application. It provides a text input box and an Eval button. The text is sent to the server for evaluation. There a service is used to evaluate the input. We’ll turn the application into an executable JAR that contains all its dependencies.

The tutorial will only use plain Maven and vi. You can of course use your own favorite editor to edit the pom and bnd files.

The result of this tutorial can be found on Github at

A disclaimer. This tutorial is about learning to use Maven to build an OSGi enRoute executable JAR, it is not about learning vi, Java, Git, nor Maven or M2Eclipse.

And as always, pull requests are highly appreciated.

What We Will Build

This tutorial will build the following application:

Application in bundles

You can find more about this form of documenting in the About OSGi section


You should create a directory somewhere in your file system, let’s say ~/workspaces/osgi.enroute.examples.eval. We are going to assume this is your default directory for your shell.

$ mkdir ~/workspaces/osgi.enroute.examples.eval
$ cd ~/workspaces/osgi.enroute.examples.eval


  1. Parent Pom – Create a Maven parent pom project
  2. API Project – How to work with bnd projects properly, API based design.
  3. Provider Bundle Project – Create a project that provides an implementation of the Eval service.
  4. Testing our Provider – Create and run JUnit tests for our provider bundle
  5. OSGi Runtime – How to create an OSGi Runtime
  6. Command Project – Create a shell command that exercises the evaluation parser
  7. Dependencies – Use a standard parser instead of our simplistic parser
  8. A Web Application – Create a one page web app that uses our evaluator
  9. Integration Testing – Run integration tests
  10. Modules – Turning the parent pom into a module pom
  11. Continuous Integration – Build the modules in continuous integration
  12. Eclipse and Bndtools – Use Eclipse to edit debug your bundles with the Bndtools editors


So, you’ve finished this tutorial! What’s next?

We’d love some feedback. Our most favorite feedback is a pull request on the documentation. As an early user you must have run into some rough edges, outright stupidities, or you had a brilliant idea. Just go to the OSGi enRoute repository on Github. Clone it in your own account, make your changes or additions, and send a pull request. We, and others like you, highly appreciate these kind of contributions.

After you’ve done this tutorial you should have a basic feeling of how to build an application using Distributed OSGi with OSGi enRoute. So the best way to continue learning is to build a small application based on these principles. Running into real problems is the best way to learn a technology. If you run into problems, use the Forum to ask questions and get answers.

And watch this space, we will expand this site with many data sheets of services you can find on the net. These data-sheets will show you how to use this service in your application with real examples.