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?

[564 byte] By [hypoglycemica] at [2007-11-26 17:36:11]
# 1
Can you show us the code you are commenting out? the one that is raising this error.
appy77a at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

gimbal2a at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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 --%>

hypoglycemica at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
:(
hypoglycemica at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

appy77a at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Check and updated, did not help.

I reinstalled tomcat to see if I had accidentally deleted something that I should have not done. No such luck.

The jsp-example sample app works with the library installed so it tells me that I have horribly broken something in my code, so I will look at that with a fine tooth comb.

hypoglycemica at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
If it still doesn't work, you can create a fresh install of everything separate from you main project, upload the WAR file and give us the URL and we can examine the WAR file to see if you are missing anything.
appy77a at 2007-7-9 0:04:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...