title: ClassNotFound considered strange
body: <p>ClassNotFound (yes, I know, there are lots of posts about this exception; I searched here and elsewhere and could not find an explanation)</p>
  
  <p>Why does Class.forName fail?</p>
  
  <pre><code>groovy&gt; class Foo { 
  groovy&gt; } 
  groovy&gt; def f = new Foo() 
  groovy&gt; def cname = f.getClass().getName() 
  groovy&gt; def p = f.getClass().getPackage() 
  groovy&gt; def l = f.getClass().getClassLoader() 
  groovy&gt; println "Foo class name: $cname" 
  groovy&gt; println "Foo package: $p" 
  groovy&gt; println "Foo class loader: ${f.getClass().getClassLoader().toString()}" 
  groovy&gt; println "Current class loader: ${this.getClass().getClassLoader().toString()}" 
  groovy&gt; try { 
  groovy&gt;     Class.forName(cname) 
  groovy&gt; } catch (Exception e) { 
  groovy&gt;     println e 
  groovy&gt; } 
  groovy&gt; l.findClass("Foo") 
  
  
  
  Foo class name: Foo
  Foo package: null
  Foo class loader: groovy.lang.GroovyClassLoader$InnerLoader@2d275595
  Current class loader: groovy.lang.GroovyClassLoader$InnerLoader@2d275595
  java.lang.ClassNotFoundException: Foo
  Exception thrown
  Oct 16, 2012 4:43:28 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize
  WARNING: Sanitizing stacktrace:
  java.lang.ClassNotFoundException: Foo
  </code></pre>
  
  <p>Thanks!</p>