Closed CodeDead closed 3 weeks ago
For anyone facing this issue, I've found a work-around by manually adding the following 'uses' statements to your mergedModule block:
jlink {
...
mergedModule {
additive = true
uses 'org.apache.logging.log4j.util.PropertySource';
uses 'org.apache.logging.log4j.core.util.ContextDataProvider';
uses 'org.apache.logging.log4j.core.util.WatchEventService';
uses 'org.apache.logging.log4j.spi.Provider';
uses 'org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory';
}
}
I filed same issue months ago here
https://github.com/beryx-gist/badass-jlink-example-log4j2-javafx/issues/5
I also manually added uses
clauses but it is not working for all cases.
Hopefully it gets fixed soon.
I just ran into this same issue, thanks for logging it, and for posting a work-around, it saved me many hours of head-scratching!
According to the log4j 2.21.0 release notes they migrated from automatic modules to named modules. This might or might not solve this problem. Note that the module names for the bridge implementations changed.
According to the log4j 2.21.0 release notes they migrated from automatic modules to named modules. This might or might not solve this problem. Note that the module names for the bridge implementations changed.
No luck there unfortunately. There's a new error message in 2.21.0: Module org.apache.logging.log4j.core does not read a module that exports javax.annotation.processing
Going to look for a work-around.
As per https://github.com/apache/logging-log4j2/issues/1896 , the solution for log4j2 2.21.0 is to do something like this in your build.gradle
file:
jlink {
forceMerge('log4j-api')
mergedModule {
additive = true
uses 'org.apache.logging.log4j.util.PropertySource'
uses 'org.apache.logging.log4j.spi.Provider'
uses 'org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory'
}
You will also need to add the following to your module-info
:
requires java.compiler;
requires java.naming;
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
Hello @CodeDead, does the problem persist with current log4j versions? There are several fixes contained in the log4j release notes for versions 2..22+. If this has been fixed, please close the issue.
Hi @xzel23
Thanks for the reminder. I just checked with Log4j2 2.24 and you still need to manually add the workaround discussed in this comment: https://github.com/beryx/badass-jlink-plugin/issues/217#issuecomment-1776917698
E.g.
...
mergedModule {
additive = true
uses 'org.apache.logging.log4j.util.PropertySource'
uses 'org.apache.logging.log4j.spi.Provider'
uses 'org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory'
}
Edit: Nevermind, the issue is fixed if you remove the forceMerge and merged Module additives!
Kind regards
Opening a new issue because after the fix from this one https://github.com/beryx/badass-jlink-plugin/issues/14
It seems like the problem has returned for log4j 2.19.0
When running the jlinked binary, you will get an error very similar to: