Why doesn’t Tomcat find my tag library or JSTL?

When I’m running the JSP examples (or some other JSP page that uses a tag library), I receive this error:

org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application

But the tag library JAR files are installed in WEB-INF/lib as the should. What’s wrong?

In most cases, you get this error because of one of these issues:

  • There’s a syntax error in your web.xml file. Check the log files and fix any problems listed there.
  • You have mistyped the uri attribute value in the taglib directive. Note that the JSTL URIs changed between the 1.0 and 1.1 version. Make sure you use the URIs that match the version you use!
  • You don’t have all (or the correct) JAR files in the WEB-INF/lib directory, e.g., you’re missing the JSTL standard.jar file or you have the JSTL 1.1 JAR files and try to use the JSTL 1.0 URIs. Note that the examples for the 2nd edition of the book come with JSTL 1.0, and the 3rd edition examples come with JSTL 1.1.
  • You’re trying to use JSTL 1.1 in a JSP 1.2 container, such as Tomcat 4. You need a JSP 2.0 container for JSTL 1.1, e.g., Tomcat 5.
  • You have taglib elements in the web.xml file that conflict with the auto-discovered tag library URIs. Remove all taglib elements from the web.xml file; you don’t need them if you use JSP 1.2 or later.
  • You have TLD files in the WEB-INF directory that conflict with the auto-discovered tag library URIs in the JAR files. Remove all separate TLD files outside of JAR files.
  • Your WEB-INF directory name isn’t in all caps, e.g., it’s something like web-inf, Web-inf or Web-Inf instead; Java is case-sensitive, and the directory name must be in all caps.

For very old versions of Tomcat (e.g., Tomcat 4.0.4) , another reason for this can be that the CATALINA_HOME/temp directory is missing, see http://issues.apache.org/bugzilla/show_bug.cgi?id=11489 for details

Create this directory if it’s missing, restart Tomcat and try again.

Leave a Reply

Your email address will not be published. Required fields are marked *