Skip to content
Happy Programming Guide
Start learning
Java

Lombok Not Working on Java 21 or 25

Getters vanish and cannot find symbol errors appear after a JDK upgrade. Lombok has to be updated for every new Java release. The version check, the build configuration, and the IDE step.

A home office desk with a computer

Lombok generates getters, setters, constructors and builders at compile time by hooking into the compiler, and every new Java release changes the compiler enough that an old Lombok stops working. After moving to Java 21 or 25, symptoms are cannot find symbol: method getName(), @Builder classes with no builder, or the build failing with an error deep in Lombok’s own code. The fix is a newer Lombok, plus the annotation-processor configuration that recent build tools require, plus the IDE plugin.

Step 1: check the version#

Lombok publishes a release shortly after each Java release with support for it. A Lombok older than the JDK you are compiling with is the cause in the majority of cases. Check what your build resolves:

Terminal
mvn dependency:tree | grep lombok
./gradlew dependencies --configuration annotationProcessor | grep lombok

Then compare with the Lombok changelog for the earliest version that mentions your JDK. As a rule, use the latest release; there is no reason to pin an old one. If the build inherits the version from a parent POM or a Spring Boot BOM, an old parent can hold Lombok back — override it explicitly.

Maven#

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

On its own, that used to be enough. Recent versions of the compiler plugin no longer scan the classpath for annotation processors, so Lombok must be declared to the compiler as well:

XML
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <release>25</release>
    <annotationProcessorPaths>
      <path>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.36</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

Both blocks: the dependency so the annotations compile, the processor path so they are acted on. If you also use MapStruct or another processor, add it to the same list, with Lombok first and the lombok-mapstruct-binding artifact alongside. Use a property for the version so the two declarations cannot drift apart.

Gradle#

GROOVY
dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.36'
    annotationProcessor 'org.projectlombok:lombok:1.18.36'

    testCompileOnly 'org.projectlombok:lombok:1.18.36'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.36'
}

All four lines. compileOnly without annotationProcessor is the classic Gradle mistake: the annotations are recognised and nothing is generated. The test configurations are separate and needed if tests use Lombok. The community Lombok Gradle plugin adds these for you if you prefer.

Step 3: the IDE#

The build can be correct and the editor still show red, because the IDE compiles separately.

  • IntelliJ: the Lombok plugin is bundled; make sure it is enabled, and turn on Enable annotation processing under Settings, Build, Compiler, Annotation Processors. Then reload the Maven or Gradle project.
  • VS Code: the Java extension pack supports Lombok automatically in current versions. Update the extensions, then Java: Clean Java Language Server Workspace.
  • Eclipse: run the Lombok jar as an installer (java -jar lombok.jar) to patch the IDE, then restart.

If mvn compile or ./gradlew build succeeds from the terminal and only the editor complains, the fix is in this section.

Errors that point elsewhere#

  • java.lang.IllegalAccessError ... module jdk.compiler does not export: an old Lombok on a new JDK. Update Lombok; nothing else fixes it.
  • Unsupported class file major version: the build plugin, not Lombok, is too old for the JDK. Update the compiler plugin or Gradle.
  • Only @Builder or @SuperBuilder broken: usually a Lombok version that predates a fix for that feature on the new JDK. Update.
  • Works in main, fails in tests: missing test annotation-processor configuration.

Consider records#

Much of what Lombok was for is now in the language. A class with only @Value or @Data plus @AllArgsConstructor is a record:

JAVA
// Lombok
@Value
public class Point { int x; int y; }

// Java 16 and later, no dependency
public record Point(int x, int y) {}

Records never break on a JDK upgrade. Keep Lombok for mutable beans, builders on large classes, and @Slf4j, and use records for immutable data. Reducing Lombok to the cases only it covers shrinks this problem each year.

Questions people ask#

Which Lombok version supports Java 25?

The latest release at the time you read this. Lombok adds support for each JDK within weeks of its release; check the changelog for the first version mentioning 25.

Does Lombok work with Java 21 LTS?

Yes, with any release from late 2023 onwards. Older versions fail with the module export error.

Is Lombok still worth using?

For builders, logging and mutable beans, many teams think so. For immutable data, records are better. It is a per-project judgement.

Why does IntelliJ show errors when the build passes?

Annotation processing is off in the IDE, or the project needs reloading after the dependency change. Both are in the IDE section above.

Where to go next#

Java records vs classes, and when Lombok is still worth itRead next

Keep reading

Java

Building a Complete Java Project

Take Java from a single file to a real project: Maven, package structure, dependency injection by hand, tests, configuration, logging and a…

7 min read

Java

Java Design Patterns

The patterns still worth knowing in modern Java — builder, strategy, factory, observer, decorator and singleton — and which the language has…

5 min read

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *