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:

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 <your-jar>.jar, the print out should read as follows:

Remember giving 0.0.0.0 as publishing address, because default is localhost/127.0.0.1. 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.

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:

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

Documentation bnd