Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

The build fails inside Lombok's annotation processor after a JDK upgrade

ErrorFatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor

Short answer

Lombok reaches into the compiler, so each new JDK needs a Lombok release that supports it. If your build image moved to a newer JDK and Lombok stayed put, javac fails inside LombokProcessor. Upgrade Lombok to a release that lists your JDK, and on JDK 23 and later declare Lombok as an annotation processor in Maven.

  • Applies to Lombok 1.18.x, JDK 17, JDK 21, JDK 25, Maven 3.9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the JDK that Maven actually compiles with and the Lombok version it resolves. A mismatch between the two is the usual story: the CI image changed its JDK without anyone touching the pom.

    mvn -version
    mvn dependency:tree -Dincludes=org.projectlombok
  2. 2Match what you see, then jump to its fix

    1. 1mvn -version shows a newer JDK than the Lombok release supportsThe Lombok version is older than the JDKFix
    2. 2The same failure only appears after moving to JDK 23 or newer, even with a recent LombokOn JDK 23 and later, Lombok is not declared as an annotation processorFix

What does the error look like?

  • Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor

Cause 1 of 2

The Lombok version is older than the JDK

1Check

Compare your Lombok version with the first release that supports your JDK: 1.18.20 for JDK 16, 1.18.22 for JDK 17, 1.18.30 for JDK 21, 1.18.32 for JDK 22, 1.18.36 for JDK 23, 1.18.38 for JDK 24, 1.18.40 for JDK 25.

mvn dependency:tree -Dincludes=org.projectlombok

2Fix

Raise Lombok to a release at or above the one for your JDK. Alternatively pin the build image back to the JDK your Lombok supports.

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.40</version>
  <scope>provided</scope>
</dependency>

3Verify

Run a clean build.

mvn -q clean compile

Confirmed by projectlombok.org

Did this fix it?

Cause 2 of 2

On JDK 23 and later, Lombok is not declared as an annotation processor

1Check

Look for an annotationProcessorPaths block in the maven-compiler-plugin configuration. Lombok's own setup page says the entry is mandatory from JDK 23 (and from JDK 9 when compiling as modules).

grep -n -A8 "annotationProcessorPaths" pom.xml

2Fix

Add Lombok to the compiler plugin's annotationProcessorPaths and keep its version equal to the dependency's version.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <annotationProcessorPaths>
      <path>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.40</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

3Verify

Rebuild from a clean state.

mvn -q clean verify

Confirmed by projectlombok.org

Did this fix it?

How do I stop it coming back?

  • Pin the JDK in the CI image (a version tag, not 'latest') so it moves only when you decide.
  • Read the Lombok changelog before raising the JDK of a project.
  • Keep the dependency version and the annotationProcessorPaths version in one Maven property.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Back end

Gradle runs no Cucumber scenarios from my feature files

Feature files exist under src/test but nothing runs

Cucumber runs on the JUnit Platform, so Gradle must call useJUnitPlatform() and have the cucumber-junit-platform-engine on the test classpath.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.