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)
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
From Netbeans IDE
Right click on a project, then presses, libraries and add just a library
That you will fire it.
JSTL lib may be missing check both jstl and servlet jars.
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.Don't forget to fix your dynamic web project facet version in project's properties accordingly.
See also: