I have an OSGi compatible kit (jar) in which I want to add a dependency jar. The dependency I want to add is the database driver. This jar is not in the lib folder of the Karaf container that I use, and there is no way to add it manually. I only have access to the deployment folder, where I can deploy my packages. I am using the maven bundle plugin to package my package. So, I wanted to know if there is a way to add a jar of dependency in my package. I am currently adding the jar manually to the kit, opening the package in 7zip and adding the jar, copying it to the jar, and it works great. I tried using the <embed-dependency> , but after that the package is not deployed. Is there any way to do this?
Below is the dependency in pom.xml that I want to add to the kit:
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.3.158</version> </dependency>
Below is the build tag in pom.xml :
<build> <defaultGoal>install</defaultGoal> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package> com.ct.service.userService.*, org.h2.* </Export-Package> <Import-Package> *, org.codehaus.jackson.jaxrs </Import-Package> <Embed-Dependency>h2</Embed-Dependency> </instructions> </configuration> </plugin> </plugins> </build>
I get the following error when trying to deploy it:
ERROR: Bundle com.ge.dsp.userService [205] Error starting file:D:Karaf/deploy/userService-0.0.1-SNAPSHOT.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle com.ge.dsp.userService [205]: Unable to resolve 205.2: missing requirement [205.2] osgi.wiring.package; (osgi.wiring.package=org.apache.lucene.analysis)) org.osgi.framework.BundleException: Unresolved constraint in bundle com.ct.service.userService [205]: Unable to resolve 205.2: missing requirement [205.2] osgi.wiring.package; (osgi.wiring.package=org.apache.lucene.analysis) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) at org.apache.felix.framework.Felix.startBundle(Felix.java:1868) at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191) at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295) at java.lang.Thread.run(Thread.java:662)
source share