title: Using Hibernate with OSGi and Maven
body: <p>I am trying to add Hibernate as a dependency of my OSGi bundle using Maven. In my POM file I have:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-osgi&lt;/artifactId&gt;
      &lt;version&gt;4.3.6.Final&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>However, when I ran that I got an error:</p>
  
  <p><em>org.osgi.framework.BundleException: Unresolved constraint in bundle org.hibernate.core [8]: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package; (&amp;(osgi.wiring.package=javax.transaction.xa)(version>=1.1.0)(!(version>=2.0.0))) [caused by: Unable to resolve 15.0: missing requirement [15.0] osgi.wiring.package; (osgi.wiring.package=javax.enterprise.context)]</em></p>
  
  <p>So I added another dependency for javax.enterprise.context:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;javax.enterprise&lt;/groupId&gt;
      &lt;artifactId&gt;cdi-api&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Which solved the previous error but lead to another error:</p>
  
  <p><em>Auto-properties install: file:///path/to/project/hibernate/target/bundles/javax.inject-1.jar (org.osgi.framework.BundleException: Could not create bundle object. - java.lang.IndexOutOfBoundsException)</em></p>
  
  <p>And now, I am unable to solve this one or even find out what causes it. I use Apache Felix.</p>