title: Extending an abstract class in the WAR from a class in the lib folder
body: <p>I want to enable the following scenario:</p>
  
  <ul>
  <li><p>my web application (WAR file) is deployed on Tomcat on its own</p></li>
  <li><p>my web application provides an API for extensions in the form of an <code>IFace</code> interface and <code>AbstractIFace</code> abstract base implementation, whose class files are deployed within the WAR file</p></li>
  <li><p>extensions to the applications are delivered as JAR files to be placed somewhere in the classpath (i.e. external to the WAR)</p></li>
  </ul>
  
  <p>I compiled a <code>ConcreteIFace</code> class which extends <code>AbstractIFace</code> and packaged it into a JAR. I put the JAR in <code>$TOMCAT_HOME/lib</code> and deployed the WAR in <code>webapps</code>. When I try the following from a servlet in the WAR:</p>
  
  <pre><code>Class clazz = Class.forName("ConcreteIFace");
  </code></pre>
  
  <p>I get the following stack trace:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: AbstractIFace
      java.lang.ClassLoader.defineClass1(Native Method)
      java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
      java.lang.ClassLoader.defineClass(ClassLoader.java:615)
      java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
      java.net.URLClassLoader.access$000(URLClassLoader.java:58)
      java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      java.security.AccessController.doPrivileged(Native Method)
      java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Class.java:247)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1698)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Class.java:169)
      com.backbase.sample.DummyServlet.service(DummyServlet.java:14)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  </code></pre>
  
  <p>A similar stack trace is presented if <code>ConcreteIFace</code> directly implements <code>IFace</code> instead of going through <code>AbstractIFace</code></p>
  
  <p>My questions are:</p>
  
  <ul>
  <li><p>as all the required classes are in the application classpath, why do I have <code>NoClassDefFound</code>?</p></li>
  <li><p>is it even possible to achieve the scenario I presented at the beginning? If so, how?</p></li>
  </ul>