title: Embedded Felix not able to cast activator to BundleActivator
body: <p><strong>Problem</strong></p>
  
  <p>I'm having a problem instantiating my OSGi bundle activator in the Felix OSGi container. When I attempt to start the bundle I get an error that I can't cast the activator type to <code>org.osgi.framework.BundleActivator</code> despite the fact this is what the parent class is defined as in the project.</p>
  
  <p>I've included <code>org.osgi:org.osgi.core:5.0.0</code> in the activated bundles so that the class that has the activator can be STARTED. Should I need to reference the OSGi library in the OSGi bundle or should the Felix container provide them for me?</p>
  
  <p>I have the same problem whether running Felix embedded or from the command line.</p>
  
  <p>** Solution **</p>
  
  <p>It turns out the version of OSGi in Felix is older than the latest standards. As I'm new to OSGi I just grabbed all of the latest things and started developing. I've moved back from version 5.0.0 to 4.3.0. The only difference I notice is the lack of nice generics in the API.</p>
  
  <p>Now that my classes are compatible they can be resolved when started in the container. Previous problems were just due to the version of the library.</p>
  
  <p><strong>Background</strong></p>
  
  <p>I have a Maven built project that wasn't starting because it couldn't find dependencies to org.osgi.framework(vesrion>=1.7.0)(!(version>=2.0.0)).</p>
  
  <p>The project configuraiton is</p>
  
  <pre><code>Main
    SubProjectApi
    SubProjectImpl
    SubProjectIntegrationTest
  </code></pre>
  
  <p>Where SubProjectImpl has a dependency to SubProjectApi. SubProjectApi has a bundle built using the maven-bundle-plugin but doesn't contain any OSGi reference. SubProjectImpl references the Api module and provides a BundleActivator. To resolve the OSGi classes the project has a dependency to <code>org.osgi:org.osgi.core:5.0.0</code>. Everything compiles fine.</p>
  
  <p>The project SubProjectIntegrationTest provides a set of unit tests to ensure the SubProjectImpl works properly within an embedded Felix environment. I've followed the guide for setting up the <code>Felix</code> instance (creating Activators, referencing the required Jars, etc.). Because the testing environment and the OSGi both need the same API classes I've used the org.osgi.framework.system.packages.extra configuration option to share the API classes.</p>
  
  <p>When the test was started the following error was produced</p>
  
  <pre><code>ERROR: Bundle dsto.lod.simr.core [12] 
      Error starting file:target/SubProjectImpl.jar 
      (org.osgi.framework.BundleException: Unresolved constraint in bundle
      project.impl [12]: Unable to resolve 12.0: 
      missing requirement [12.0] osgi.wiring.package; 
      (&amp;(osgi.wiring.package=org.osgi.framework)(version&gt;=1.7.0)(!(version&gt;=2.0.0))))
  </code></pre>
  
  <p>I thought the Felix environment would automatically provide those classes. I added the org.osgi.core module into the environment the problem changed to the one I have with casting types.</p>