title: OSGi: how to ensure classpath consistency?
body: <p>According to the OSGi documentation, OSGi is designed to help prevent ClassPath problems.</p>
  
  <p>For example, from "OSGi in action":</p>
  
  <blockquote>
    <p>ClassNotFoundExceptions when starting your application because the
    class path wasn't correct. OSGi can help by ensuring that code
    dependencies are satisfied before allowing the code to execute.</p>
  </blockquote>
  
  <p>However, since we've switched our java application to OSGi, I see more ClassNotFoundExceptions and especially NoClassDefFoundErrors than ever. Classes that were previously loading fine are not found anymore by the OSGI classloader, and worse: you get the error at run-time, which means that you can't easily check for it except by manually testing every corner of your application.</p>
  
  <p>For example, our application was running happily under OSGi, but we received reports from beta testers that they couldn't export documents to PDF anymore. Indeed, when I looked into it, I found that this functionality caused an exception to be logged:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/w3c/dom/Node
  </code></pre>
  
  <p>So, is OSGi actually creating more classpath problems than it solves? </p>
  
  <p>and more importantly: How can I test that my class-path is consistent, with all necessary Import-Package statements etc. <strong>before</strong> I read about them in bug reports?</p>