I followed the guide in this link to install JSTL but I got the following error when I tried to launch my JSP page:
java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator
The taglib declaration is:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
I installed JSTL 1.1 under /WEB-INF/lib
in Tomcat webapps and tried to do the same in my project, but it didn't work. I also tried version 1.2 of JSTL and still the same message. How is this caused and how can I solve it?
The javax.servlet.jsp.tagext.TagLibraryValidator class is introduced in JSP 2.0 and then later repackaged to jakarta.servlet.jsp.tagext.TagLibraryValidator in JSP 3.0. This error can thus have the following possible causes:
You are not running a JSP 2.0 compatible servletcontainer. For example, Tomcat 4.x or 5.0. You need a Tomcat version between 5.5 and 9.0.
You are actually running a JSP 3.0 compatible servletcontainer (the first version with jakarta package instead of javax) such as Tomcat 10.0 or newer. In that case you'll need to upgrade JSTL from 1.x to 2.0 or newer. Installation instructions can be found in How to install JSTL? It fails with "The absolute uri cannot be resolved" or "Unable to find taglib" or NoClassDefFoundError or ClassCastException.
You have cluttered the /WEB-INF/lib
with arbitrarily downloaded jsp-api.jar
or j2ee.jar
or javaee.jar
files or whatever contains the JSP API, which originates from a completely different servletcontainer make/version which in turn was actually not JSP 2.0 compliant. Get rid of those libraries. You don't need them. If you did this to workaround compilation errors, then you did it the wrong way. They should end up in compiletime classpath, not in the runtime classpath. See also How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?