Skip to content
Latchkey

Lombok "cannot find symbol" for getters/setters - Fix Annotation Processing in CI

The compiler could not find Lombok-generated members (getX(), builder(), the all-args constructor). Lombok generates them during annotation processing; if processing is disabled or Lombok is not registered as a processor, the methods never get created and every call site fails to compile.

What this error means

Compilation fails with cannot find symbol: method getName() (or builder(), setX()) on classes annotated @Data/@Getter/@Builder. The annotation is present but its output is missing.

java
error: cannot find symbol
    String name = user.getName();
                      ^
  symbol:   method getName()
  location: variable user of type User

Diagnose it: get the real failure out of Gradle

Gradle summarises failures aggressively, and the top-level message frequently describes a downstream symptom rather than the cause. Re-run the failing task with diagnostics before changing build logic.

Terminal
# the actual stack, plus what Gradle decided about the build
./gradlew <task> --stacktrace --info

# is a stale daemon or cache involved?
./gradlew --stop
./gradlew <task> --no-daemon --no-build-cache

# what does Gradle think the environment is?
./gradlew -version

Common causes

Lombok not on the annotationProcessor path

Lombok is declared as implementation/compileOnly only; without annotationProcessor, modern Gradle/Maven does not run it.

Annotation processing disabled

A -proc:none flag, or a build that turned off processing, prevents Lombok from generating anything.

IDE compiled but CI did not

The IDE has the Lombok plugin so it "works locally," while the CI compiler has no processor configured.

How to fix it

Register Lombok as a processor (Gradle)

Declare both the API (compileOnly) and the processor.

gradle
dependencies {
  compileOnly 'org.projectlombok:lombok:1.18.34'
  annotationProcessor 'org.projectlombok:lombok:1.18.34'
  testCompileOnly 'org.projectlombok:lombok:1.18.34'
  testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
}

Register Lombok as a processor (Maven)

Add Lombok to the compiler plugin annotationProcessorPaths.

pom.xml
<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.34</version></path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

Do not disable annotation processing

Ensure no -proc:none is passed to javac in the build.

Terminal
# remove any -proc:none from compilerArgs / options.compilerArgs

Configuration cache and CI

  • The configuration cache rejects build logic that reads mutable state at execution time, which is why enabling it surfaces errors an existing build never showed.
  • Run with --configuration-cache-problems=warn first to see the full list rather than failing on the first one.
  • A cached configuration keyed to a different environment is worse than none. Include the JDK version in your cache key.

How to prevent it

  • Always pair Lombok compileOnly with annotationProcessor in every module.
  • Never set -proc:none on modules that use Lombok.
  • Cover compilation in CI so missing accessors fail there, not just in the IDE.

Frequently asked questions

What causes Lombok "cannot find symbol" for getters/setters?
There are 3 common causes: lombok not on the annotationprocessor path, annotation processing disabled, and ide compiled but ci did not. Lombok is declared as implementation/compileOnly only; without annotationProcessor, modern Gradle/Maven does not run it.
How do I fix Lombok "cannot find symbol" for getters/setters?
There are 3 fixes depending on which cause you have: register lombok as a processor (gradle), register lombok as a processor (maven), and do not disable annotation processing. Work through them in order, since the first is the most common.
What does Lombok "cannot find symbol" for getters/setters actually mean?
Compilation fails with cannot find symbol: method getName() (or builder(), setX()) on classes annotated @Data/@Getter/@Builder.
How do I stop Lombok "cannot find symbol" for getters/setters happening again?
Always pair Lombok compileOnly with annotationProcessor in every module. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card