OSGi Bundle not starting with Felix Host application

I am using Apache Felix in a host application to provide the ability to load extensions at runtime. The mechanism works great but I have some very temperamental behaviour regarding the bundles starting if I include certain dependencies. If for example I use the following in my pom.xml:


                    <Include-Resource>{maven-resources}, {maven-dependencies}</Include-Resource>

Everything works perfectly and the bundle registers and starts. However if I include async-http-client in the bundle it registers but does not start! I have tried embedding the dependency in the bundle even though the parent exposes it by the parent host application. If I look inside the compiled bundle the jar has been included but it still wont actually start.

I tried adding:


and modified:

<Embed-Dependency>jackson-core, async-http-client</Embed-Dependency>

Neither of these options work. I am not getting any error in the host application and I just can't work out why some libraries cause this but not others.


The Jackson can be accessed as OSGi bundles you don't need to embed it. If you have felix webconsole or other type of console you can check what import (or capability) is not presented which causes that the bundle cannot came to ACTIVE state. As the POM shows all dependecies included in transitive form. It's not a good idea to use that, because it means no classes loaded from other bundles, instead of everything is embeded, which means you create a monolithic bundle which is not using anything from bundles.

Another possible reason to not start is that the activator calls some method which throws an exception which will invalidate your activator, as the OSGi spec defines. Recommended to check your log, maybe there is some reflection instantiate classes in the code which cannot be resolved, because its not manifested by bundle plugin - only that packages can be imported which are presented in classes import's.

After further investigation it turns out that the problem is related to versioning. The bundle MANIFEST.MF that is created explicitly states the versions for some import packages:

Import-Package: ...,com.fasterxml.jackson.core.type;version="[2.4,3)",com.ning.http.client;version="[1.9,2)",

However, the host application does not specify a version:

Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA -> ... com.ning.http.client ...

It appears that the version must be explicitly stated in the host and it must match the bundles import otherwise the bundle won't activate.

Need Your Help

Way to figure out / retrieve Windows username in Oracle APEX

windows oracle oracle-apex

I wanted to know, if there is a way to just get the Windows username with some kind of function, ... in Oracle APEX 4.2 an populate it a Display Only element in an application page. I don't want to...

HTML page encoding problems

javascript html encoding utf-8

I am having some trouble with a website I am creating, I am using Adobe Dreamweaver to just write code in, not using its visual builder.