title: Using an embedded OSGi container
body: <p>I am building some modules which I want to expose as OSGi bundles without any actual dependencies to OSGi libraries. It would seem that this is possible using the declarative services option.</p>
  
  <p>However because I'm rather new to OSGi (at least on the bundle-creating side) I want to test if it all works as it should, to this end I want to set up a small embedded OSGi environment.</p>
  
  <p>Currently I have a single bundle which exports an API and also provides a stub implementation of a single interface.</p>
  
  <p>I have followed the following tutorials to set up an environment:</p>
  
  <ul>
  <li><a href="http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html" rel="nofollow noreferrer">http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html</a></li>
  <li><a href="https://stackoverflow.com/questions/1887809/how-to-start-and-use-apache-felix-from-code">How to start and use Apache Felix from code?</a></li>
  </ul>
  
  <p>And the embedded felix implementation seems to work properly however there are two problems:</p>
  
  <pre><code>Bundle bundle = felix.getBundleContext().installBundle("/path/to/bundle.jar")
  bundle.start();
  System.out.println(bundle.getRegisteredServices());
  </code></pre>
  
  <p>This prints out <code>null</code> so while the bundle is seemingly started ok, it does not seem to expose any services.</p>
  
  <p>Secondly I'm wondering whether I have to do anything special to get the declarative services bit up and running. My maven dependencies are:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
          &lt;artifactId&gt;org.apache.felix.framework&lt;/artifactId&gt;
          &lt;version&gt;4.2.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
          &lt;artifactId&gt;org.apache.felix.scr&lt;/artifactId&gt;
          &lt;version&gt;1.6.2&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>Based on the email thread found here: <a href="http://mail-archives.apache.org/mod_mbox/felix-users/201111.mbox/%3CAE48C9B8172EFC48A028B60E8D6F96660143A5F336@sausexmbp02.amd.com%3E" rel="nofollow noreferrer">http://mail-archives.apache.org/mod_mbox/felix-users/201111.mbox/%3CAE48C9B8172EFC48A028B60E8D6F96660143A5F336@sausexmbp02.amd.com%3E</a></p>
  
  <p>I tried to add the bundle to the felix startup properties:</p>
  
  <pre><code>map.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.apache.felix.scr; version=1.6.2");
  </code></pre>
  
  <p>However this seems a bit optimistic at first glance. How do I enable the declarative services for an embedded felix engine?</p>