Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apache Log4j Tag Library not working on tomcat 10.1.34 #3401

Open
pischky opened this issue Jan 17, 2025 · 2 comments
Open

Apache Log4j Tag Library not working on tomcat 10.1.34 #3401

pischky opened this issue Jan 17, 2025 · 2 comments

Comments

@pischky
Copy link

pischky commented Jan 17, 2025

Description

I'm trying to port a project using JSP from Tomcat 9 to Tomcat 10.1.34 but "Apache Log4j Tag Library" ("log4j-taglib-2.24.3.jar")
is not working anymore.

Configuration

log4j-taglib-2.24.3.jar

Winows 7

Java 21.0.2 / Oracle

Logs

HTTP Status 500 – Internal Server Error

Type Exception Report

Message java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/BodyTagSupport

Beschreibung The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

jakarta.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/BodyTagSupport
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:70)

Root Cause

java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/BodyTagSupport
java.base/java.lang.ClassLoader.defineClass1(Native Method)
java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2350)
org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2219)
org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:813)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1335)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1183)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1244)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1477)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:264)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:109)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:367)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:331)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:396)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:377)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:325)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:70)

Root Cause

java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.BodyTagSupport
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1374)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1183)
java.base/java.lang.ClassLoader.defineClass1(Native Method)
java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2350)
org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2219)
org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:813)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1335)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1183)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1244)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1477)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:264)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:109)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:367)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:331)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:396)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:377)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:325)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:70)

Hinweis Der komplette Stacktrace der Ursache ist in den Server logs zu finden

Reproduction

<%@ taglib prefix="log" uri="http://logging.apache.org/log4j/tld/log" %>
<log:setLogger logger="/index.jsp" />

@ppkarwasz
Copy link
Contributor

I'm trying to port a project using JSP from Tomcat 9 to Tomcat 10.1.34 but "Apache Log4j Tag Library" ("log4j-taglib-2.24.3.jar")
is not working anymore.

The log4j-taglib artifact only supports JavaServer Pages 2.3 (part of Java EE 8) or earlier releases. As you are probably aware, Jakarta Server Pages 3.0 and later (part of Jakarta EE 9) uses a new jakarta.* namespace for classes, instead of the javax.* namespace, which is a breaking change. Currently we don't plan any version of log4j-taglib compatible with JSP 3.0 (see documentation) and the log4j-taglib artifact is scheduled for removal in Log4j Core 3.

Could you tell us more about your application? Are you still using log4j-taglib in production? There are multiple reasons for the deprecation:

  • according to our download statistics, the log4j-taglib artifact is barely used.
  • most of the tools we used to generate the artifact (e.g. taglib-maven-plugin) have gone EOL.
  • since modern JSP pages are only used as HTML templates and don't contain Java code any more, we believe that the need for logging in a JSP page has disappeared.
  • Apache Log4j has a lot of components and we don't have enough time to ensure that all the components are high quality. In particular log4j-taglib needs some love.

@pischky
Copy link
Author

pischky commented Jan 17, 2025

Thanks for the explanation. I will think about replacing log4j-taglib-2.24.3.jar in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants