JSTL exploding
When I import the JSTL into a page, any page, I get the following error:
java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator
When I comment out the include at the top, all is well and the <c:out> and <c:for> etc are all rendered as regular text, as it should do.
I am running on osx 10.4.8, tomcat 5.5.20 and java 1.5.0
I have standard.jar and jstl.jar in the shared/lib folder so I am really confused why I get a NoClassDefError.
What am I doing wrong? How can I diagnose the problem more?
# 2
Alright, three questions:
1) do you have the following at the top of your web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
2) does your taglib uri look like this:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3) in the common/lib, or in the lib of your webapp, is there another standard.jar present? If so you should remove it.
# 3
1)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2eee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
My IDE (intellij) has a cry if I dont have
xsi:schemaLocation="http://java.sun.com/xml/ns/j2eee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
and not
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
but the error happens wither way
check
2)
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
Check
3) Check, no duplicates.
I even removed the jar from the jsp-examples webapp.
Here is my jsp (simplified to illustrate point) that will produce the error:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://com.mysite" prefix="mysite" %>
<jsp:useBean id="ArticleProcessBean" scope="page" class="com.mysite.beans.ArticleProcessBean"/>
<jsp:include page="/WEB-INF/jspf/header.jspf" /> <%-- Insert the header --%>
<c:forEach var="articleList" items="${ArticleProcessBean.articles}">
<mysite:article newsArticle="${articleList}"/>
</c:forEach>
<jsp:include page="/WEB-INF/jspf/footer.jspf" /> <%-- Insert the footer --%>
And with commented out taglib declaration:
<%-- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> --%>
<%@ taglib uri="http://com.mysite" prefix="mysite" %>
<jsp:useBean id="ArticleProcessBean" scope="page" class="com.mysite.beans.ArticleProcessBean"/>
<jsp:include page="/WEB-INF/jspf/header.jspf" /> <%-- Insert the header --%>
<c:forEach var="articleList" items="${ArticleProcessBean.articles}"> <-- These 2 lines are interpreted as regular html (which it should)
<%--<mysite:article newsArticle="${articleList}"/>--%> (Null pointer if not commented out)
</c:forEach> <-- line 2
<jsp:include page="/WEB-INF/jspf/footer.jspf" /> <%-- Insert the footer --%>
# 5
Someone else had this same problem before:
http://mail-archives.apache.org/mod_mbox/jakarta-taglibs-user/200503.mbox/%3C1109943834.4228661ae511c@webmail.dotech.com%3E
Check for a few things ,
1) in your web.xml it should be like this ( there should not be a new line after xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee , the value of xsi:schemaLocation should all fall on *one* line :
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
Message was edited by:
appy77