java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory in @Observes StartupEvent in GraalVM
See original GitHub issueDescribe 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:
- See above code
Configuration n/a
Screenshots n/a
Environment (please complete the following information):
- GraalVM version (if different from Java): 0-19.2.0.1
- Quarkus version or git rev: 0.23.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
org.apache.commons.logging.LogFactory exception - Stack ...
I have already included common-logging1.1.1.jar and spring.jar file. Could you please help to out? Exception in thread "main" java.lang.
Read more >org.apache.commons.logging.LogFactory - Mkyong.com
Starting a web application, but hits the following error messages : ... Caused by: java.lang.ClassNotFoundException: ...
Read more >org.apache.commons.logging.LogFactory - Java - Code2care
How to resolve Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception.
Read more >2020 quarkus-fascicle-understanding-v1.pdf
Logger JUL_LOGGER = java.util.logging.Logger.getLogger(LoggingResource.class.getName()); org.apache.commons.logging.Log COMMONS_LOGGING =.
Read more >chore(deps): update dependency io.quarkus:quarkus ... - GitLab
An error occurred while retrieving approval data for this merge request. chore(deps): update dependency io.quarkus:quarkus ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My use case: commons-logging is used int the Apache HTTP client, which itself is used in AWS’ S3 Client.
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.