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

Several ClassNotFoundException warnings after upgrading to 2.23.x #2835

Closed
mihalyr opened this issue Aug 12, 2024 · 4 comments · Fixed by #2836
Closed

Several ClassNotFoundException warnings after upgrading to 2.23.x #2835

mihalyr opened this issue Aug 12, 2024 · 4 comments · Fixed by #2836
Labels
bug Incorrect, unexpected, or unintended behavior of existing code
Milestone

Comments

@mihalyr
Copy link

mihalyr commented Aug 12, 2024

Description

Updating log4j from 2.22.1 to 2.23.0 or 2.23.1 causes a long list of warnings with exception traces for ClassNotFound exceptions for various class files.

Configuration

Version: 2.23.1 (latest)

Operating system: Linux 6.9.12-200.fc40.x86_64 (Fedora 40)

JDK: OpenJDK Runtime Environment Corretto-21.0.4.7.1 (build 21.0.4+7-LTS)

Logs

2024-08-12T20:55:04.848574234Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AbstractAsyncExceptionHandler.class java.lang.NoClassDefFoundError: com/lmax/disruptor/ExceptionHandler
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.addIfMatching(ResolverUtil.java:462)
	at org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.loadImplementationsInJar(ResolverUtil.java:357)
	at org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.findInPackage(ResolverUtil.java:236)
	at org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.loadFromPackage(PluginRegistry.java:224)
	at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:162)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:242)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:313)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:631)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:713)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:735)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:260)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:154)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:46)
	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:197)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:611)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:597)
	at LoggingTest.test(LoggingTest.java:4)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:728)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
	at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
	at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
	at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:218)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:214)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:139)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
	at jdk.proxy1/jdk.proxy1.$Proxy4.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:198)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:130)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:101)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:61)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:122)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:69)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.ClassNotFoundException: com.lmax.disruptor.ExceptionHandler
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 106 more

I could not paste in the full log due to GitHub issue description restrictions, but this same exception trace continues for 36 other classes:

2024-08-12T20:55:04.848574234Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AbstractAsyncExceptionHandler.class java.lang.NoClassDefFoundError: com/lmax/disruptor/ExceptionHandler
2024-08-12T20:55:04.863010652Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AsyncLogger.class java.lang.NoClassDefFoundError: com/lmax/disruptor/EventTranslatorVararg
2024-08-12T20:55:04.876041935Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AsyncLoggerConfigDefaultExceptionHandler.class java.lang.NoClassDefFoundError: com/lmax/disruptor/ExceptionHandler
2024-08-12T20:55:04.888450291Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor$Log4jEventWrapperHandler.class java.lang.NoClassDefFoundError: com/lmax/disruptor/EventHandler
2024-08-12T20:55:04.897193640Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor$Log4jEventWrapperHandler3.class java.lang.NoClassDefFoundError: com/lmax/disruptor/SequenceReportingEventHandler
2024-08-12T20:55:04.905696861Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/AsyncLoggerDefaultExceptionHandler.class java.lang.NoClassDefFoundError: com/lmax/disruptor/ExceptionHandler
2024-08-12T20:55:04.920293618Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/JCToolsBlockingQueueFactory$MpscBlockingQueue.class java.lang.NoClassDefFoundError: org/jctools/queues/MpscArrayQueue
2024-08-12T20:55:04.927522991Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/RingBufferLogEvent$Factory.class java.lang.NoClassDefFoundError: com/lmax/disruptor/EventFactory
2024-08-12T20:55:04.934415933Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/RingBufferLogEventHandler.class java.lang.NoClassDefFoundError: com/lmax/disruptor/SequenceReportingEventHandler
2024-08-12T20:55:04.940426224Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/RingBufferLogEventHandler4.class java.lang.NoClassDefFoundError: com/lmax/disruptor/EventHandler
2024-08-12T20:55:04.945727999Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.class java.lang.NoClassDefFoundError: com/lmax/disruptor/EventTranslator
2024-08-12T20:55:04.950998911Z Test worker WARN Could not examine class org/apache/logging/log4j/core/async/TimeoutBlockingWaitStrategy.class java.lang.NoClassDefFoundError: com/lmax/disruptor/WaitStrategy
2024-08-12T20:55:05.019943924Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ContextDataAsEntryListDeserializer$1.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/type/TypeReference
2024-08-12T20:55:05.024074847Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ContextDataAsEntryListDeserializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/deser/std/StdDeserializer
2024-08-12T20:55:05.027251789Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ContextDataAsEntryListSerializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/StdSerializer
2024-08-12T20:55:05.030348787Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ContextDataDeserializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/deser/std/StdDeserializer
2024-08-12T20:55:05.033280449Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ContextDataSerializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/StdSerializer
2024-08-12T20:55:05.038999610Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ListOfMapEntryDeserializer$1.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/type/TypeReference
2024-08-12T20:55:05.041876744Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ListOfMapEntryDeserializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/deser/std/StdDeserializer
2024-08-12T20:55:05.044439136Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ListOfMapEntrySerializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/StdSerializer
2024-08-12T20:55:05.046922512Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jJsonModule.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/module/SimpleModule
2024-08-12T20:55:05.049423181Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jJsonObjectMapper.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
2024-08-12T20:55:05.052247462Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/deser/std/StdScalarDeserializer
2024-08-12T20:55:05.055034067Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jXmlModule.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/xml/JacksonXmlModule
2024-08-12T20:55:05.057853644Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jXmlObjectMapper.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/xml/XmlMapper
2024-08-12T20:55:05.060703167Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jYamlModule.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/module/SimpleModule
2024-08-12T20:55:05.063480087Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/Log4jYamlObjectMapper.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/yaml/YAMLMapper
2024-08-12T20:55:05.069304136Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/MessageSerializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/StdScalarSerializer
2024-08-12T20:55:05.072218547Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/MutableThreadContextStackDeserializer$1.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/type/TypeReference
2024-08-12T20:55:05.075429779Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/MutableThreadContextStackDeserializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/deser/std/StdDeserializer
2024-08-12T20:55:05.078320940Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/ObjectMessageSerializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/StdScalarSerializer
2024-08-12T20:55:05.080930354Z Test worker WARN Could not examine class org/apache/logging/log4j/core/jackson/SimpleMessageDeserializer.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/deser/std/StdScalarDeserializer
2024-08-12T20:55:05.097624264Z Test worker WARN Could not examine class org/apache/logging/log4j/core/layout/JacksonFactory$Log4jXmlPrettyPrinter.class java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/xml/util/DefaultXmlPrettyPrinter
2024-08-12T20:55:05.118612683Z Test worker WARN Could not examine class org/apache/logging/log4j/core/net/SmtpManager$SMTPManagerFactory$1.class java.lang.NoClassDefFoundError: javax/mail/Authenticator
2024-08-12T20:55:05.129174092Z Test worker WARN Could not examine class org/apache/logging/log4j/core/osgi/Activator.class java.lang.NoClassDefFoundError: org/osgi/framework/SynchronousBundleListener
2024-08-12T20:55:05.197387855Z Test worker WARN Could not examine class org/apache/logging/log4j/util/Activator.class java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
2024-08-12T20:55:05.203295573Z Test worker WARN Could not examine class org/apache/logging/log4j/util/ProviderActivator.class java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator

Reproduction

I have a very small reproducer for this

build.gradle

plugins {
    id 'java'
}

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.apache.logging.log4j:log4j-core:2.23.1'
    testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
}

test {
    useJUnitPlatform()
}

src/test/resources/log4j2-test.properties

status = info
packages = org.apache.logging.log4j
appender.console.type = Console
appender.console.name = console
rootLogger = info, console

src/test/java/LoggingTest.java

public class LoggingTest {
  @org.junit.jupiter.api.Test
  void test() {
    org.apache.logging.log4j.LogManager.getLogger();
  }
}

Execute with ./gradlew test -i --rerun or in you IDE.

I have noticed the following:

  1. If I downgrade to 2.22.1 the problem goes away
  2. If I remove packages from the log4j2-test.properties file the problem also goes away

However, there is a reason, why I still use packages for some plugins, various annotation processors configured used to cause issues and I was never able to make log4j plugin discovery work without the packages configuration. But that is a separate issue, packages is still supported in 2.23.x, so this should still work the same way it did on 2.22.x, IMO. As a workaround, I can just downgrade to 2.22.1 for now.

@ppkarwasz
Copy link
Contributor

@mihalyr,

The warning statements you are seeing were always present in the Log4j codebase, but were only visible if the verbose attribute of the configuration was set to true. The verbose attribute was deprecated in version 2.23.0.

Since many Log4j plugins require additional dependencies, we should probably add a special clause to handle a LinkageError in:

} catch (final Throwable t) {
LOGGER.warn("Could not examine class {}", fqn, t);
}

@mihalyr
Copy link
Author

mihalyr commented Aug 13, 2024

Thank you for the clarification, I was not aware of this, probably did not use verbose mode before.

It seems this does not affect functionality, but adds several thousand lines of traces to every application boot at WARN level which makes following the application startup much harder. And this is also present in test output where loggers are loaded.

If these are useful messages for some for troubleshooting, maybe we could make it DEBUG or lower so they are hidden at least on status = info level?

I did not notice the name of the plugins causing the exceptions either. I was wondering if there was a way to disable the offending ones or just be more explicit about which ones to load?

@vy
Copy link
Member

vy commented Aug 13, 2024

It seems this does not affect functionality, but adds several thousand lines of traces to every application boot at WARN level which makes following the application startup much harder. And this is also present in test output where loggers are loaded.

@mihalyr, thanks so much for the report. I will try to make sure this is resolved in the next major release, i.e., 2.24.0. The current behaviour is indeed undesired.

If these are useful messages for some for troubleshooting, maybe we could make it DEBUG or lower so they are hidden at least on status = info level?

That can indeed be a resolution. Regardless of that, I'd advise you to

  1. Avoid using status property in the Log4j configuration files (see the soon-to-be-released documentation for details)
  2. Instead pass the log4j2.statusLoggerLevel system/JVM property
  3. Use level WARN (Status Logger is intended for troubleshooting Log4j internals. There is no need to display its logs unless you're having a problem, in which case, will be communicated with messages of severity WARN or higher.)

I did not notice the name of the plugins causing the exceptions either. I was wondering if there was a way to disable the offending ones or just be more explicit about which ones to load?

This is a complicated issue. In short, there are several optional dependencies and you only get to know them while trying to load them. 🤷

Since many Log4j plugins require additional dependencies, we should probably add a special clause to handle a LinkageError in: ...

@ppkarwasz, I doubt if a whitelist of exceptions will cut it. Why don't we rather change the logged status message severity to DEBUG instead. addIfMatching() receives a Test, and for a class that is failing to load, it surely cannot pass. Hence ignoring such addIfMatching() invocations sounds sensible to me.

@vy vy added bug Incorrect, unexpected, or unintended behavior of existing code and removed waiting-for-maintainer labels Aug 13, 2024
@vy vy added this to the 2.24.0 milestone Aug 13, 2024
ppkarwasz added a commit that referenced this issue Aug 13, 2024
This improves status logger warnings about:

* missing `Log4j2Plugin.dat` plugin descriptors,
* usage of package scanning.

The warnings are reworded in a way that they are more useful to end-users.
If package scanning is enabled, linkage errors (almost exclusively due to optional dependencies) are logged at a `DEBUG` level instead of `WARN`.

This addresses @vlsi suggestions from
apache/jmeter#5937 (comment) and fixes #2835.
@ppkarwasz
Copy link
Contributor

Since many Log4j plugins require additional dependencies, we should probably add a special clause to handle a LinkageError in: ...

@ppkarwasz, I doubt if a whitelist of exceptions will cut it. Why don't we rather change the logged status message severity to DEBUG instead. addIfMatching() receives a Test, and for a class that is failing to load, it surely cannot pass. Hence ignoring such addIfMatching() invocations sounds sensible to me.

That is what I meant. Linkage errors (NoClassDefFound) mean that an optional dependency is missing. I would keep catching other types of exceptions (like the unlikely ClassNotFoundException):

} catch (final LinkageError e) {
LOGGER.debug("Could not scan class {}, since an optional dependency is missing.", fqn, e);
} catch (final Exception e) {
LOGGER.warn("Could not scan class {}.", fqn, e);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect, unexpected, or unintended behavior of existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants