26

I am using sitemesh to decorate the pages. I am using a JSP page for this. The page worked fine until I used the <c:if> conditional tag. I have the jstl-impl-1.2.jar & sitemesh-3.0-alpha-1.jar files in the WEB-INF/lib folder. I have following tag library declarations in the jsp page:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

I am using tomcat 7.0 with java 6. When I created the new dynamic web project in eclipse, I set the dynamic web module version to 2.4. The page has <c:set/> tags, they are working fine, but when I use the if conditional tag I get the following error:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/ConditionalTagSupport
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:342)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.sitemesh.webapp.WebAppContext.dispatch(WebAppContext.java:158)
org.sitemesh.webapp.WebAppContext.decorate(WebAppContext.java:133)
org.sitemesh.BaseSiteMeshContext.decorate(BaseSiteMeshContext.java:39)
org.sitemesh.webapp.SiteMeshFilter.postProcess(SiteMeshFilter.java:74)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:175)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)
org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:157)

root cause

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/ConditionalTagSupport
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(Unknown Source)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1223)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)
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:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.sitemesh.webapp.WebAppContext.dispatch(WebAppContext.java:158)
org.sitemesh.webapp.WebAppContext.decorate(WebAppContext.java:133)
org.sitemesh.BaseSiteMeshContext.decorate(BaseSiteMeshContext.java:39)
org.sitemesh.webapp.SiteMeshFilter.postProcess(SiteMeshFilter.java:74)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:175)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)
org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:157)

root cause

java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.ConditionalTagSupport
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(Unknown Source)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1223)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)
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:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.sitemesh.webapp.WebAppContext.dispatch(WebAppContext.java:158)
org.sitemesh.webapp.WebAppContext.decorate(WebAppContext.java:133)
org.sitemesh.BaseSiteMeshContext.decorate(BaseSiteMeshContext.java:39)
org.sitemesh.webapp.SiteMeshFilter.postProcess(SiteMeshFilter.java:74)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:175)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)
org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:157)
6
  • Which jstl-impl jar? If you're using the Apache taglibs you'd need both the jstl and standard jar. Commented Nov 8, 2011 at 2:39
  • @DaveNewton I am not sure, i downloaded it from the Glassfish server site.
    – Ghost-Man
    Commented Nov 8, 2011 at 3:20
  • Grab the API jar as well; that should do it. If it does, I'll move this into an answer. If it doesn't, I'll... just wonder what's wrong. Commented Nov 8, 2011 at 3:22
  • @DaveNewton I am not at my PC now. It will take few hours until i try this, but i'll surely let you know as it seems it will work. Thanks !!
    – Ghost-Man
    Commented Nov 8, 2011 at 3:37
  • @DaveNewton yes you were right, i was missing the API jar, adding it worked. Thanks again. You can convert it into an answer. +1
    – Ghost-Man
    Commented Nov 8, 2011 at 14:14

4 Answers 4

56

This exception suggests that the JSTL API is missing in the runtime classpath. You seem to have only the JSTL impl. I suggest to remove it and use jstl-1.2.jar instead which has both the API and impl bundled.

Further, I'd also recommend to update your web.xml root declaration to comply Servlet 3.0 spec. JSTL 1.2 requires a minimum of Servlet 2.5, so it won't work very well with a Servlet 2.4 targeted project. As Tomcat 7 is a Servlet 3.0 container and Servlet 3.0 offers a lot of new cool features over 2.5, I'd go for it.

<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_3_0.xsd"
    version="3.0">

Don't forget to fix your dynamic web project facet version in project's properties accordingly.

See also:

1
  • 2
    @BalusC You know, when I posted this question I was hoping if you would answer. Because I knew, if you would answer then it will be not just the appropriate solution but also the extra points that I might be missing or doing wrong. Thank you very much. I got the problem here and no doubt your solution worked.
    – Ghost-Man
    Commented Nov 8, 2011 at 14:12
-1

maybe you must add also the javax.servlet.jsp.jstl-api-1.2.x.jar to your classpath. You're only declaring a specific implementation, without the core API. I had the same problem and I solved in this way. Regards, Giacomo

-1

JSTL lib may be missing check both jstl and servlet jars.

0
-4

From Netbeans IDE

Right click on a project, then presses, libraries and add just a library

That you will fire it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.