Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
After upgrading to 4.0.4 the application will no longer start when using log4j2 with the log4j-spring-boot extension when packaged in a fat-jar.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:106)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.IllegalAccessError: class org.apache.logging.log4j.spring.boot.Log4j2SpringBootLoggingSystem tried to access method 'void org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.<init>(java.lang.ClassLoader)' (org.apache.logging.log4j.spring.boot.Log4j2SpringBootLoggingSystem and org.springframework.boot.logging.log4j2.Log4J2LoggingSystem are in unnamed module of loader org.springframework.boot.loader.launch.LaunchedClassLoader @3f91beef)
at org.apache.logging.log4j.spring.boot.Log4j2SpringBootLoggingSystem.<init>(Log4j2SpringBootLoggingSystem.java:77)
at org.apache.logging.log4j.spring.boot.Log4j2SpringBootLoggingSystem$Factory.getLoggingSystem(Log4j2SpringBootLoggingSystem.java:266)
at org.springframework.boot.logging.DelegatingLoggingSystemFactory.getLoggingSystem(DelegatingLoggingSystemFactory.java:46)
at org.springframework.boot.logging.LoggingSystem.get(LoggingSystem.java:170)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:239)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:222)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:180)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:173)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:151)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:133)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:137)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:76)
at org.springframework.boot.SpringApplicationRunListeners.lambda$starting$0(SpringApplicationRunListeners.java:56)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:123)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:56)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
Metadata
Metadata
Assignees
Labels
No labels
Activity
wilkinsona commentedon Mar 23, 2026
Initially, I couldn't reproduce the described behavior, but I think I'd made some faulty assumptions. The problem isn't specific to running a fat jar and wasn't introduced in 4.0.4.
It was introduced in 7d34320, which was a contribution from a Log4j2 maintainer which made the constructor package-private. We can consider making it public again but minimising the visibility is preferable.
@ppkarwasz, what are the plans for
Log4j2SpringBootLoggingSystemin relation to 7d34320.@elmuerte, for what purpose are you using
log4j-spring-boot? You may not need it any more.elmuerte commentedon Mar 23, 2026
Looks like a few projects were still using it, but I see that it is no longer needed since Spring Boot 3 as all the features
log4j-spring-bootprovides the same functionality.So I'm removing that dependency where we are still using it.
So, maybe add a notice to the release notes that people should remove
log4j-spring-bootwhen upgrading to 4.0.4wilkinsona commentedon Mar 23, 2026
The release notes for 3.0 already mentioned the new features in Boot's Log4j2 integration. I've updated the relevant section to also mention that a dependency on
log4j-spring-bootcan typically be removed.ppkarwasz commentedon Mar 23, 2026
Hi @elmuerte,
That is correct:
log4j-spring-bootonly targets Spring Boot 2, while in Spring Boot 3+ the module should be removed. We did document this fact, but apparently we missed some spots:We would love PRs that fix those pages. Log4j's documentation uses Antora and each page has an “Edit this page” link in the upper right corner.