title: How to include a jar of dependency in an OSGi bundle using maven bundle plugin?
body: <p>I have an OSGi compliant bundle(jar), in which I want to add a jar of a dependency. The dependecy I want to add is of a Database Driver. That jar is not present in the lib folder of the Karaf container which I am using, and there is no way of adding it there manually. I have access only to the deploy folder, where I can deploy my bundles. I am using maven bundle plugin to package my bundle. So, I wanted to know whether there is a way to add the dependency jar in my bundle. Currently, I am adding the jar manually to the bundle by opening the bundle in 7zip and adding the jar by copying it in the jar and it works fine. I tried using the <code>&lt;embed-dependency&gt;</code> tag, but after doing that the bundle doesn't gets deployed. Is there <strong>any</strong> way to do it ?</p>
  
  <p>The following is the dependency in <code>pom.xml</code> which I want to add in the bundle:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;com.h2database&lt;/groupId&gt;
          &lt;artifactId&gt;h2&lt;/artifactId&gt;
          &lt;version&gt;1.3.158&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>The following is the build tag in <code>pom.xml</code>:</p>
  
  <pre><code>&lt;build&gt;
      &lt;defaultGoal&gt;install&lt;/defaultGoal&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
              &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
              &lt;extensions&gt;true&lt;/extensions&gt;
              &lt;configuration&gt;
                  &lt;instructions&gt;
                      &lt;Export-Package&gt;
                          com.ct.service.userService.*,
                          org.h2.*
                      &lt;/Export-Package&gt;
                      &lt;Import-Package&gt;
                          *,
                          org.codehaus.jackson.jaxrs
                      &lt;/Import-Package&gt;
                      &lt;Embed-Dependency&gt;h2&lt;/Embed-Dependency&gt;
                  &lt;/instructions&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>I get the following error when I try to deploy it:</p>
  
  <pre><code>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)
  </code></pre>