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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With