I’m facing an intermittent StackOverflowError during compilation after adding Lombok to my project even though I’m not using any Lombok annotations yet.
Environment
Java 21
Spring Boot 2.7
Maven Compiler Plugin 3.1
Build command:
mvn clean packageAlso occurs with IntelliJ internal compiler
Problem
After adding Lombok as a dependency (with provided scope), the build behaves inconsistently:
Sometimes the project compiles successfully
Other times it fails with a
StackOverflowErrorduring compilationThe error occurs both via Maven and IntelliJ
Important:
I am not using any Lombok annotations in the code yet, just adding the dependency triggers the issue.
Additional Context
We are already using a Log4j annotation processor configured with:
only
This is set in a custom execution (process-classes phase).
Some team members suspect this might be related, but:
This configuration has existed for a long time
Its original purpose is unclear
Removing it is currently not an option due to unknown impact on the system
What I’ve Tried
Added Lombok with
providedscopeTried excluding Lombok from annotation processing
Clean builds (
mvn clean)Rebuilding multiple times
Despite this, the issue still occurs randomly.
Question
Why would simply adding Lombok (without using any annotations) cause a
StackOverflowErrorduring compilation?Could this be related to annotation processing conflicts (e.g., with
)?only Is there a way to prevent Lombok from interfering with annotation processing entirely?