title: Eclipse 4 Injecting an OSGI Service
body: <p>I want to turn a <code>Settings</code> class into an OSGI declarative service which e4 can inject.</p>
  
  <p>I have created the service in <em>OSGI-INF/settingsService.xml</em>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.recommenders.privacy.rcp"&gt;
          &lt;implementation class="org.eclipse.recommenders.privacy.rcp.PrivacySettingsService"/&gt;
      &lt;service&gt;
          &lt;provide interface="org.eclipse.recommenders.privacy.rcp.IPrivacySettingsService"/&gt;
      &lt;/service&gt;
  &lt;/scr:component&gt;
  </code></pre>
  
  <p>And I have annotated the variable with <code>@Inject</code> as described here:
  <a href="http://toedter.com/2010/06/28/eclipse-4-0-dependency-injection-and-osgi-declarative-services/" rel="nofollow">http://toedter.com/2010/06/28/eclipse-4-0-dependency-injection-and-osgi-declarative-services/</a></p>
  
  <pre><code>@Inject
  private IPrivacySettingsService privacySettingsService;
  </code></pre>
  
  <p>But I am getting a <code>NullPointerException</code>.</p>