Spring Boot facing problem with jstl (JSP)

238 Views Asked by At

I am working with Spring boot with jstl problem when i call the jsp page it return the error of validation

[2m[nio-9090-exec-1][0;39m [36mo.a.c.c.C.[.[localhost].[/].[jsp]       [0;39m [2m:[0;39m Servlet.service() for servlet [jsp] threw exception

java.lang.ClassCastException: class org.apache.taglibs.standard.tlv.JstlCoreTLV cannot be cast to class jakarta.servlet.jsp.tagext.TagLibraryValidator (org.apache.taglibs.standard.tlv.JstlCoreTLV and jakarta.servlet.jsp.tagext.TagLibraryValidator are in unnamed module of loader 'app')
    at org.apache.jasper.compiler.TagLibraryInfoImpl.createValidator(TagLibraryInfoImpl.java:356) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:195) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:429) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:487) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1444) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Parser.parse(Parser.java:138) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:245) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.ParserController.parse(ParserController.java:106) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:211) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:396) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:372) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:396) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328) ~[tomcat-embed-jasper-10.1.15.jar:10.1.15]

i have install the maven dependency as mentioned below.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>   
</dependency>

But it still returns the error mentioned above.

1

There are 1 best solutions below

4
Kavindu Gayan On

The error message indicates that there is a conflict between the JSTL implementation provided by the application and the JSTL implementation provided by the container. The application is using the JSTL 1.2 implementation, while the container is using the Jakarta JSP Taglib API (jakarta.servlet.jsp.tagext) implementation.

To resolve this issue, you can either upgrade the JSTL implementation provided by the application to Jakarta JSP Taglib API or downgrade the container to one that supports JSTL 1.2.

Remove the JSTL 1.2 dependency from the application's pom.xml file. Add the Jakarta JSP Taglib API dependency to the application's pom.xml file. Update the JSTL taglib declaration in the JSP pages to use the Jakarta JSP Taglib API URI. Here is an example of how to update the JSTL taglib declaration:

<%@ taglib prefix="c" uri="http://jakarta.servlet.jsp/jstl/core" %>

Once you have either upgraded the JSTL implementation provided by the application or downgraded the container, you should be able to run your JSP pages without encountering the ClassCastException.