title: JSP / JSTL causes NoClassDefFound error for TagSupport
body: <p>This problem has been driving me mad for several weeks now and I suspect that the resolution, once I find it, will be simple.  I have looked at every relevant answer I can find in StackOverflow but haven't managed to resolve it, so I am hopeful that someone will be able to help me.</p>
  
  <p>I have re-created the problem in a very simple web app for simplicity so I hope this will make it easier for people to help.</p>
  
  <p>Here is the (simplified) problem:</p>
  
  <ul>
  <li><p>I have a Java EE web app which comprises a single JSP which uses the Core JSTL Tag Library.</p></li>
  <li><p>I have downloaded the two JSTL jars which I believe are relevant.  These are:</p>
  
  <p><code>javax.servlet.jsp.jstl-1.2.1.jar</code> and <code>javax.servlet.jsp.jstl-api-1.2.1.jar</code></p></li>
  <li><p>I have placed these two files in my Tomcat lib folder.</p></li>
  <li><p>In my simplified web app there is no app library (WEB-INF/lib) so I am pretty sure I haven't duplicated the files anywhere else within the application.</p></li>
  <li><p>I am referencing servlet 2.5 in web.xml.</p></li>
  </ul>
  
  <p>When I run the app I get the following error (edited to include full stack trace):</p>
  
  <pre><code>java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.TagSupport
      java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      java.security.AccessController.doPrivileged(Native Method)
      java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
      java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      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)
      sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
      java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      java.lang.ClassLoader.loadClass(ClassLoader.java:295)
      sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      java.lang.ClassLoader.loadClass(ClassLoader.java:295)
      java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      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:249)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
      org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1223)
      org.apache.jasper.compiler.Parser.parseElements(Parser.java:1452)
      org.apache.jasper.compiler.Parser.parse(Parser.java:138)
      org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
      org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
      org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  </code></pre>
  
  <p>Here is my jsp file, index.jsp</p>
  
  <pre><code>&lt;%-- Created by IntelliJ IDEA. --%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Test JSP&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;
          Test Heading
      &lt;/h1&gt;
      &lt;c:if test="true"&gt;
          &lt;p&gt;True&lt;/p&gt;
      &lt;/c:if&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is my web.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             version="2.5"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;myjsp&lt;/servlet-name&gt;
          &lt;jsp-file&gt;/index.jsp&lt;/jsp-file&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;myjsp&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/myjsp&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Finally, for what it is worth, here is a list of files within my Tomcat lib folder:</p>
  
  <pre><code>annotations-api.jar
  catalina-ant.jar
  catalina-ha.jar
  catalina-tribes.jar
  catalina.jar
  ecj-4.2.2.jar
  el-api.jar
  jasper-el.jar
  jasper.jar
  javax.servlet.jsp.jstl-1.2.1.jar
  javax.servlet.jsp.jstl-api-1.2.1.jar
  jsp-api.jar
  servlet-api.jar
  tomcat-api.jar
  tomcat-coyote.jar
  tomcat-dbcp.jar
  tomcat-i18n-es.jar
  tomcat-i18n-fr.jar
  tomcat-i18n-ja.jar
  tomcat-jdbc.jar
  tomcat-util.jar
  </code></pre>
  
  <p>NOTE:</p>
  
  <p>In my original app I was using a version 3.0 web.xml but I am getting the same error using 2.5.</p>
  
  <p>I have found that if I change the tag lib declaration within the jsp file from</p>
  
  <pre><code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  </code></pre>
  
  <p>to </p>
  
  <pre><code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt;
  </code></pre>
  
  <p>I get exactly the same error, which surprises me.  I would have thought I would get something like TLD file not found type error without the "/jsp" in the declaration, so I wonder whether that is a clue?</p>
  
  <p>If I comment out the core tags (<code>&lt;c:if ...&gt;</code>) The jsp works and displays the text.</p>
  
  <p>I hope there is enough information here for people to help.  If you need any further clarification then let me know.</p>