title: Possible reasons for NoClassDefFoundError
body: <p>I'm getting the following <code>NoClassDefFoundError</code>, which is weird because the class is already present in the library jar.</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: abc/test/Test.java
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:795)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:144)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:382)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:75)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:294)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:795)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:144)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:382)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:75)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:294)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:432)
  Caused by: java.lang.ClassNotFoundException: abc.test.Test
          at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 25 more
  </code></pre>
  
  <p>This looks like its not able to find the same class which is causing the exception.
  I have also included the library path in ant <code>build.xml</code>, which can be verified below. </p>
  
  <pre><code>&lt;property name="deps" value="${lib}/abclib/abclib-test.jar"/&gt;
  
  &lt;target name="dist" depends="compile"&gt;
          &lt;manifest file="${dist}/MANIFEST.MF"&gt;
              &lt;attribute name="Main-Class" value="xyz.test.TestConfiguration" /&gt;
              &lt;attribute name="Class-Path" value="${deps}"/&gt;
          &lt;/manifest&gt;
          &lt;jar jarfile="${dist}/abc.jar" basedir="${build}/" manifest="${dist}/MANIFEST.MF" /&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>I'm lost, can someone at least guide me where should I look or what I might be doing wrong?</p>
  
  <p>Also, can someone throw light, "Exception" and "Caused by". I'm not quite getting how are they two related.</p>