Describe the bug
Running the in OpenJDK, the following code works
public void startup(@Observes StartupEvent ev) {
org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("test");
logger.info("test");
org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("init");
log.info("init");
}
... but in GrallVM, org.slf4j.Logger can be initialized, but org.apache.commons.logging.Log can not, and one gets the following exception:
java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
at org.apache.commons.logging.impl.LogFactoryImpl.class$(LogFactoryImpl.java:210)
at org.apache.commons.logging.impl.LogFactoryImpl.<init>(LogFactoryImpl.java:221)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(DynamicHub.java:778)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1047)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
at java.security.AccessController.doPrivileged(AccessController.java:69)
at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:624)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:669)
at test.Job.startup(ExporterJob.java:199)
at test.Job_Observer_startup_f43ab41051de39ca1e534f6cd06115c3c9b219b8.notify(Job_Observer_startup_f43ab41051de39ca1e534f6cd06115c3c9b219b8.zig:51)
at io.quarkus.arc.EventImpl$Notifier.notify(EventImpl.java:228)
at io.quarkus.arc.EventImpl.fire(EventImpl.java:69)
at io.quarkus.arc.runtime.LifecycleEventRunner.fireStartupEvent(LifecycleEventRunner.java:23)
at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:99)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent29.deploy_0(LifecycleEventsBuildStep$startupEvent29.zig:77)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent29.deploy(LifecycleEventsBuildStep$startupEvent29.zig:36)
at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:229)
at io.quarkus.runtime.Application.start(Application.java:93)
at io.quarkus.runtime.Application.run(Application.java:213)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:34)
Expected behavior
Once a class is loaded (i.e. org.apache.commons.logging.LogFactory) subsequent class lookup should not result in a java.lang.NoClassDefFoundError.
Actual behavior
org.apache.commons.logging.LogFactory is loaded and methods invoked, but when a class that implements that interface is loaded, it fails to load.
To Reproduce
Steps to reproduce the behavior:
Configuration
n/a
Screenshots
n/a
Environment (please complete the following information):
What does your project pom look like, especially the dependencies that you have included?
This is the pom that I used:
pom.xml.txt
This is kinda expected, there's no support for commons-logging, while there's explicit code to allow SLF4J support: the idea was to support SLF4J as it's very common.
@dmlloyd should we treat commons-logging the same as slf4j?
Yes. We could use org.jboss.logmanager:commons-logging-jboss-logmanager
for this purpose
We already use org.jboss.logging:commons-logging-jboss-logging
for this. I think there is some other problem going on here though; see #5361.
My use case: commons-logging is used int the Apache HTTP client, which itself is used in AWS' S3 Client.
Also, the Quarkus documentation lists commons logging as one of the supported APIs.
If you include the artifact I referenced, that should enable you to work around the problem. You might have to manually add exclusions for commons-logging:commons-logging-api
though.
Most helpful comment
My use case: commons-logging is used int the Apache HTTP client, which itself is used in AWS' S3 Client.