Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
10.0.0-M2
-
None
Description
Accessing commons-logging throws an exception when it is being invoked in an application that has a log4j2 dependency but no commons-logging dependency. Might possibly also be a commons-logging bug? Really not sure
The layout is basically:
- tomee
- libs/
- commons-logging.jar
- webapps/ROOT/WEB-INF/libs
- log4j2-api/core.jar
- libs/
This causes the following to happen:
- commons-logging checks the current thread classloader for a log4j2 class
- if it finds one, it creates an instance of Log4jApiLogFactory
- while doing so, java tries to load the class org.apache.logging.log4j.spi.LoggerAdapter using the classloader that loaded commons-logging.jar
- ClassNotFoundException with a very incomprehensible stacktrace
See attached reproducer, simply run mvn package tomee:run
Stacktrace:
Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/spi/LoggerAdapter at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:375) at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:419) at org.apache.commons.logging.LogFactory.lambda$newFactory$3(LogFactory.java:1431) at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:1431) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:928) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:987) at com.example.ExampleBean.initApplication(ExampleBean.java:15) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:569) at org.apache.webbeans.event.ObserverMethodImpl.invoke(ObserverMethodImpl.java:410) at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:371) ... 49 more Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.spi.LoggerAdapter at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ... 64 more
Attachments
Attachments
Issue Links
- relates to
-
TOMEE-4394 Commons Logging 1.3.4
- Resolved