title: How do I ensure my OSGi fragments get installed before the host bundle?
body: <p>I am trying to deploy guice into JBoss AS7 (7.2.0-Alpha). This comes as a number of jars. The ones I am interested in are</p>
  
  <ul>
  <li>guice</li>
  <li>guice-servlet</li>
  <li>guice-persist</li>
  </ul>
  
  <p>guice is the a host bundle and guice-servlet and guice-persist are fragments of this host.</p>
  
  <p>When I start the container the host bundle always gets installed, resolved and becomes active. The fragments always get installed and sometimes get resolved and "included" in the host bundle and sometimes don't. This seems to be random.</p>
  
  <p>I have also tried Eclipse Virgo and the behaviour is the same, but, it has the ability to define plans whereby you can circumvent this problem by defining the installation order. (I seemed to be able to make it work anyway).</p>
  
  <p>Looking at the OSGi spec and reading the answer to this <a href="https://stackoverflow.com/questions/11029768/when-is-an-osgi-fragment-attached-to-host">question</a> it seems like this is the expected behaviour. JBoss is an OSGi 4.2 container so the the <code>Require-Capability</code> and <code>Provide-Capability</code> headers aren't an option - plus I don't really want to modify jars which aren't mine.</p>
  
  <p>How am I supposed to get my host/fragment bundles to install and resolve reliably?</p>
  
  <p>One idea I have had (which I am reluctant to do as it doesn't seem right) is to use maven-bundle-plugin/bndtools and merge the guice bundles together into a single super-guice-bundle - effectively doing at build time what the container is failing to do for me at runtme.</p>