Remote launching OSGi applications with bnd

Recently, I wanted to build an OSGi application that should run on my RaspberryPi. So I wanted an easy way to test this application on the Pi. After some research I found the possibility to use a remote laucher in bnd.

There are two parts necessary for that:

  • the remote agent
  • the local launcher

Configure the remote agent

The remote-agent for an existing framework can be configured with a bndrun-file like this:

-runfw: org.apache.felix.framework;version='[5.6.10,5.6.10]'
-runee: JavaSE-1.8

-resolve.effective: active;skip:="osgi.service"

-runpath: \

-runproperties: \

With this there is just a OSGi framework running including the remote agent, that listens on port 29998. Just export this setup to a single jar and copy it to your remote system. You need to ensure that the given port is not secured by a firewall.

After starting the exported jar on your remote machine with java -jar .jar, the print out should read as follows:

Host 29998

Remember giving as publishing address, because default is localhost/ The default does not work for remote communication between different hosts.

Configure your local laucher

The bndrun-file for you IDE should extended in the following way.

remote = \
	remote; \
	host = your-host

-runremote: ${remote}

-runpath: \

Now you run this bndrun as Run as -> Bnd Native Launcher. If the connection is established you can see it in the console as headline remote - yourhost:29998. You also should notice that something happens on you remote machine console output. In the documenation linked below you can find further possibilities to configure the remote agent for e.g. remote debugging as well.

If the file is lauched used by the default laucher you will receive a message like this:

Error: Could not find or load main class ...

Make sure you you use Run as -> Bnd Native Launcher to avoid this mistake!

Documentation bnd

by Ilenia Salvadori, Mark Hoffmann, Jürgen Albert