title: ClassNotFoundException while dynamic class loading in JBoss 7.1.1 from OSGi-bundle
body: <p>I deployed a simple OSGi test-bundle into JBoss 7.1.1 and try to dynamically instantiate the Jacorb ORB by doing </p>
  
  <pre><code>Class clazz = Class.forName("org.jacorb.orb.ORB");
  </code></pre>
  
  <p>All I got is </p>
  
  <pre><code>java.lang.ClassNotFoundException: org.jacorb.orb.ORB from [Module "deployment.test:1.0.0" from Service Module Loader]
  </code></pre>
  
  <p>What I already did:</p>
  
  <ul>
  <li>in the JBoss configuration <code>standalone.xml</code> I added for the osgi-subsystem the capability <code>&lt;capability name="org.jacorb" startlevel="1"/&gt;</code>, so that the <code>org.jacorb</code> module is loaded. That already solved the problem, that the installation of my test bundle fails.</li>
  <li><p>I declared the <code>Dependencies</code>-Descriptor on <code>org.jacorb</code> in my <code>MANIFEST.MF</code> (also tried with and without the <code>export</code> option): <code>Dependencies: org.jacorb export</code></p></li>
  <li><p>I added the <code>jboss-deployment-structure.xml</code> to my <code>META-INF</code> with the following content</p>
  
  <p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
     &lt;jboss-deployment-structure&gt;
       &lt;deployment&gt;
         &lt;dependencies&gt;
           &lt;module name="org.jacorb" /&gt;
         &lt;/dependencies&gt;
       &lt;/deployment&gt;
     &lt;/jboss-deployment-structure&gt;</p></li>
  </ul>
  
  <p>Also I did experiments with the ClassLoaders and realized, that the ContextClassLoader is <code>null</code>. But in the end, I cannot effect this as the non-test-code, because the <code>Class.forName()</code> cannot be changed to use a specific classloader.</p>
  
  <p>So why do I get this ClassNotFoundException?</p>
  
  <p>Thanks in advance</p>
  
  <p>Alex</p>