Adding Bundle Dependency to AWS SDK

Hi everyone,

I’m currently building a binding for the Enera project (
Because they are using AWS Cognito as their Identity Provider, I tried to add the aws-java-sdk as a dependency.
As the SDK is huge, Amazon provides the possibility to add only certain modules as dependencies (see the docs).
Unfortunately, the standard SDK is not OSGi compatible, which leads to errors about missing requirements. They do provide an OSGi compatible package for the 1.x version of their SDK, but this does not allow for modular dependencies, and also is not available for 2.x.
As Java is not my usual battle ground, I’m a bit lost and am hoping for help…

I’ve not tried it myself but the documentation suggests that you can ask for a dependency to be “wrapped” to make it OSGi compatible by adding something to src/main/feature/feature.xml:

Hours of trial and error later, I now have almost all dependencies needed to communicate with Cognito included. The problem does not seem to be the OSGi compatilibity, but the fact that Maven does not see (and resolve) all dependencies that Karaf sees.
I now have >15 manually added dependencies inside my pom.xml.

Additionally, I’d need to create a file etc/ to resolve dependency to the package, and I am not sure I am allowed to do that in the openHAB context. Also, I didn’t get this to work, so the verify step keeps complaining:

Message: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-enera; type=karaf.feature; version=2.5.4.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-enera)(type=karaf.feature)(version>=2.5.4.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-enera/2.5.4.SNAPSHOT: missing requirement [openhab-binding-enera/2.5.4.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.enera; type=osgi.bundle; version="[,]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.enera/ missing requirement [org.openhab.binding.enera/] osgi.wiring.package; filter:="("]]

There has been some work osgifying AWS SDK in by @J-N-K.

Dynamo persistence binding is also hooked to AWS SDK, see openHAB 3.x work done here:

In 1.x version, the SDK was “vendored” in lib/:

Hopefully this is of help.

Thank you very much @ssalonen!

Your hint to look at the pom.xml for the dynamodb persistence bundle sent me down the right track.

To summarize, things I learned (from the standpoint who barely understands the complexity of OSGi, Karaf, its features, dependency management of maven etc…):

  1. in contrast to having a maven-only project, one has to include many dependencies manually: in my test project I only needed dependencies to aws-java-sdk-cognitoidentity and aws-java-sdk-cognitoidp, in the OSGi world, I needed to include 18 dependencies!
  2. for all packages that need to be resolved using the JDK libs, instead of using the documented way outlined above (creating etc/ etc.), the <bnd.importpackage> directive in pom.xml seems to also satisfy the verify build step

So, after 2 days of hard work I can actually start working on the binding :wink:

1 Like