Karaf Features : runtime complaining about missing Import, whilst is has been included at compile time


I have an old binding that I need to upgrade to 3.3.x. That binding uses some of the Apache Commons dependencies that have been removed in 3.3.x . So, I include the dependencies explicitly into Maven’s pom.xml with a compile scope, as if it where a regular external dependency that is not provided by a feature bundle by the Karaf runtime. Yet, the Karaf runtime complains it can not resolve that given package (“Unresolved requirement: Import-Package: org.apache.commons.io.output”). Why is that, since I do not declare it in feature.xml of that binding anyways ? it should be compiled into the binding’s .jar no?

Any help is appreciated


Verify a target/features.xml file and if it includes the maven dependency as well. Depending on the dependency scope it might not be automatically included.

Ok, but I don’t expect the dependency to be provided by the karaf container. So then it should not be included in features.xml, right?

The scope of the maven dependency is compile, not provide

I think prior 3.1 commons was included by some core dependencies. It changed at some point of time (can’t remember when). If you compare contents of openhab-runtime-base feature all bindings depend you will find a reason for failure.
To make your feature resolve just add <bundle>mvn:commons-io/commons-io/xyz</bundle> in src/main/feature file. You can twist commons-io dependency scope to see which one causes automatic inclusion in there as I can’t find a clear reference in docs how it goes.

Maybe this Removal of dependency on 'org.apache.commons.*' · Issue #7722 · openhab/openhab-addons · GitHub ??


What I don’t understand that a maven dependency that is included with “compile” scope is not included in the final jar, and gets resolved by the karaf container instead. Like with any other “external” dependency I would imagine it gets packaged into the jar

Just checking. Are you running the eclipse demo application or in an openHAB runtime environment?

It is a runtime environment. The problem, obviously, is not there in the non-karaf world

Ok, so, even if you do not want karaf to provide a package/dependency, you still have to declare it explicitly in features.xml in order to have things resolve in the Karaf container.

It is what it is basically


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.