This post details the steps to create and deploy OSGI bundle out of third party API/dependency using relevant plugins in simple maven project.
We would have been in situation where OSGi bundle created out of third party jar is added/available in our instance and our project code base using the third party bundle being in active state. However at the time of execution, ClassNotFound or NoClassDefFound error pops up.
This is the case when the dependencies of our desired third party API is not included/available when it is added as an OSGi bundle.
We can overcome this by creating the bundle using maven-bundle-plugin which has option to include
1. direct(desired third party dependency - highlighted in red in below screenshot -
-->* - to include all the dependency entry in the pom.xml file or
-->artifactId name if we would like to mention explicitly
-->Note : There are several other possible options documented for in official plugin page (Mentioned the link at the end in Reference section)
2. transitive dependencies (dependencies which our third party API is dependent on - highlighted in green in below screenshot is responsible for the same)
With this plugin information in the tag + third party dependency of our interest in section along with details like group id, artifact id in pom.xml file will help create OSGi bundle using the command - mvn package or mvn clean package