Skip to main content
  1. My Blog posts/

(not) Developing OSGi applications with IDEA

·626 words·3 mins·
medium osgi
Víctor (Bit-Man) Rodríguez
Author
Víctor (Bit-Man) Rodríguez
Algorithm Junkie, Data Structures lover, Open Source enthusiast

(not) Developing OSGi applications with IDEA #

In my search for OSGi perfection :-) one of the goals is to make the transition from development time to runtime as seamless as possible, this means no surprises at runtime (avoid NullPointerException, ClassNotFoundException and other Precambrian creatures). This can be materialized as being able to have the same classes available in runtime and devtime, which in this case is accomplished by making IDEA to search for classes, or unless packages, through OSGI

Starting from the very beginning just noticed that an additional plugin is required to enable OSGi support : Osmorc.

The first blow came from A Guide to Developing OSGi applications with Osmorc in IntelliJ IDE where it clearly establishes that the way I want devtime == runtime == OSGi

it is not the one that this plugin works

Anyway I decided to give it a try.

The second blow wasn’t far away. During the setup a checkbox named “” needs to be checked. This are the reasons to do so :

Enabling “Create and maintain the module FrameworkInstance” will cause a new module with the name “FrameworkInstance” to be created. This module references all bundle jars of the framework instance used for the project. Why would you need such a module? As long as you don’t import any package from a framework module, the corresponding global library isn’t referenced anywhere in your project. As long as a global library isn’t referenced in a project, you won’t be able to navigate to it by “Go To Class” action. So when your framework instances contain some specific bundles — Spring or SWT for example -, you won’t be able to search for classes inside those bundles. That’s where that new module comes in. It references all global libraries belonging to your chosen framework and makes them searchable from the project. You will find them with the “Go To Class” or you can just browse through all available bundles by browsing through the libaries of that special module. It’s definitely not the best way to present the contents of a framework instance, but for the time being it works. No problem just being aware of how it works is just part of this research. Let’s move on !! Setting up my first project was easy, but mistakes are easily made. I forgot to use my good luck charm and I created a Java project that was not Maven enabled, then added couple of modules and added them OSGi and OSGi bundle facet : upon setting close and try to re-opening an error established that I was no able to do so blew into my face. Disable Apache Felix to be able to re-open modules settings was the only solution. After this error is fixed a new Run configuration was added then executed and the OSGi framework started … sorry, not started :

___
/ /
/ / Oops, there has been a problem!
/ /
/__/ Platform [platform.felix 4.1.2] is not supported
___
/__/ Use –log=debug to see details.

The issue is not the plugin per-se but PAX, then have to replace (PAX) in plugins folder for a new version . Just decided to download v1.8.5 , and copy it into folder $HOME/.IdeaIC12/config/plugins/Osmorc/lib using filename pax-runner-1.5.0.jar

no alternate text for image

Guess what ?

We need a newer OSGi plugin, because the current one is aimed at Apache Felix Integration for IntelliJ IDEA 10 & 11 (what about v12 and v13 ??) being the 1.3.4 the latest release from plugin repositories. Alas v1.3.5 can be build from sources even that seems to be no changes since 1 year.

Better luck next time pals, or better vote for OSGi support on a level similar to BndTools.

Update Nov 21, 2013: added link to “” bug.