title: org.osgi.framework.BundleException: Unresolved constraint in bundle SampleModel
body: <p>I am trying to launch an OSGi framework programatically. I am using Felix framework for this. Below is the code I have which will launch an OSGi container.</p>
  
  <pre><code>public GoldeneyeApp() {
  
      try {
  
          FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
          Map&lt;String, String&gt; config = new HashMap&lt;String, String&gt;();
  
          //TODO: add some config properties
          Framework framework = frameworkFactory.newFramework(config);
          framework.start();
  
          BundleContext bundleContext = framework.getBundleContext();
  
          modulesNameVersionHolder.put("SampleModel", "1.0.0");
  
          List&lt;Bundle&gt; installedBundles = new LinkedList&lt;Bundle&gt;();
  
          String basePath = "C:\\ClientTool\\LocalStorage";
  
          for (Map.Entry&lt;String, String&gt; entry : modulesNameVersionHolder.entrySet()) {
  
              String version = entry.getValue();
              final String filename = name + Constants.DASH + version + Constants.DOTJAR;
              final String localFilename = Constants.FILE_PROTOCOL + basePath+ File.separatorChar + filename;
  
              installedBundles.add(bundleContext.installBundle(localFilename));
          }   
  
          for (Bundle bundle : installedBundles) {
              bundle.start(); // this line throws an exception as soon as I start SampleModel bundle
          }
      } catch (BundleException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>In the above code, I am trying to install and start a simple OSGi module (SampleModel jar) that I have created. As soon as I try to start that module, I always get the below exception-</p>
  
  <pre><code>org.osgi.framework.BundleException: Unresolved constraint in bundle SampleModel [6]: Unable to resolve 6.0: missing requirement [6.0] osgi.wiring.package; (&amp;(osgi.wiring.package=net.sf.cglib.core)(version&gt;=2.1.3)(!(version&gt;=3.0.0)))
      at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
      at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
      at com.host.stream.goldeneye.GoldeneyeApp.&lt;init&gt;(GoldeneyeApp.java:62)
      at java.lang.J9VMInternals.newInstanceImpl(Native Method)
      at java.lang.Class.newInstance(Class.java:1345)
      at com.host.jetstream.application.JetstreamApplication.getInstance(JetstreamApplication.java:71)
      at com.host.jetstream.application.JetstreamApplication.main(JetstreamApplication.java:94)
  </code></pre>
  
  <p>Below is my SampleModel pom.xml file-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;com.host.Domain&lt;/groupId&gt;
          &lt;artifactId&gt;DomainParent&lt;/artifactId&gt;
          &lt;version&gt;1.6.1-RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;!-- POM Information about the Project --&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.host.sample.model&lt;/groupId&gt;
      &lt;artifactId&gt;SampleModel&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
  
      &lt;!-- Packing Type is bundle for OSGI Library Bundle --&gt;
      &lt;packaging&gt;bundle&lt;/packaging&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;org.springframework.beans&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;org.springframework.context&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;org.springframework.core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.servicemix.bundles&lt;/groupId&gt;
              &lt;artifactId&gt;org.apache.servicemix.bundles.cglib&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.osgi&lt;/groupId&gt;
              &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
              &lt;version&gt;4.3.0&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$ --&gt;
              &lt;type&gt;jar&lt;/type&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.osgi&lt;/groupId&gt;
              &lt;artifactId&gt;org.osgi.compendium&lt;/artifactId&gt;
              &lt;version&gt;4.3.0&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$ --&gt;
              &lt;type&gt;jar&lt;/type&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;!-- Build Configration --&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;!-- Apache Felix Bundle Plugin - For Generation of Manifest after Compile phase --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;manifestLocation&gt;src/main/resources/META-INF&lt;/manifestLocation&gt;
                      &lt;instructions&gt;
                          &lt;Bundle-SymbolicName&gt;SampleModel&lt;/Bundle-SymbolicName&gt;
                          &lt;Bundle-Activator&gt;com.host.sample.model.samplemodel.activator.Activator&lt;/Bundle-Activator&gt;
                          &lt;Import-Package&gt;*,
                              org.springframework.beans.factory;version="[3.0.5.RELEASE,4.0.0)",
                              org.springframework.beans.factory.config;version="[3.0.5.RELEASE,4.0.0)",
                              net.sf.cglib.core;version="[2.1.3,3.0.0)",
                              net.sf.cglib.proxy;version="[2.1.3,3.0.0)",
                              net.sf.cglib.reflect;version="[2.1.3,3.0.0)"
                          &lt;/Import-Package&gt;
                      &lt;/instructions&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;!-- Configuration of repositories for dependency resolution --&gt;
      &lt;repositories&gt;
          &lt;!-- Domain Bundles Repository --&gt;
          &lt;!-- This is needed to locate the Domain Parent project. Other repositories 
              come from the parent. --&gt;
          &lt;repository&gt;
              &lt;id&gt;releases&lt;/id&gt;
              &lt;url&gt;http://nxDomain/content/repositories/releases/&lt;/url&gt;
              &lt;releases&gt;
              &lt;/releases&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;thirdparty&lt;/id&gt;
              &lt;url&gt;http://nxDomain/content/repositories/thirdparty/&lt;/url&gt;
              &lt;releases&gt;
              &lt;/releases&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  &lt;/project&gt;
  </code></pre>