Matched signals
- COMPILATION ERROR :
- duplicate class:
- is already defined in class
- cannot find symbol
- Compilation failure: Compilation failure:
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
Maven Java compilation failure
What this failure means
The Maven compiler plugin failed during compilation. Common causes are duplicate class definitions, missing symbols from a recently changed API, or generated sources that are no longer in sync with the code.
Symptoms
Faultline looks for one or more of these log fragments:
COMPILATION ERROR :
duplicate class:
is already defined in class
cannot find symbol
Compilation failure: Compilation failure:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
Diagnosis
Maven surfaced a COMPILATION ERROR from the maven-compiler-plugin. The
javac errors underneath it identify the root cause:
- duplicate class — the same class is defined more than once, often because generated source directories are also committed, or a class was moved without removing the original.
- is already defined in class — an inner class or enum constant appears twice in the same compilation unit. Usually caused by a failed merge or a code generator run that appended to an existing file.
- cannot find symbol — a method, field, or type that the code references no longer exists. Frequently triggered by a Lombok, MapStruct, or other annotation-processor model change that happened in a different commit.
Fix steps
Duplicate class
-
Search for all copies of the class file:
find . -name "DuplicateClass.java" -not -path "*/target/*" -
Remove the stale copy or the generated source directory from
pom.xml<sourceDirectory>/<testSourceDirectory>. -
Clean the build cache:
mvn clean compile
Cannot find symbol
-
Check whether the missing symbol was removed or renamed in a recent commit:
git log --oneline -5 -- path/to/ChangedClass.java -
Re-run the annotation processor (Lombok, MapStruct, etc.) if the symbol is generated:
mvn clean generate-sources compile -
Verify that the IDE-generated
target/generated-sourcesis not excluded from the Maven source root configuration.
Validation
mvn clean test-compile— must exit 0 with noCOMPILATION ERRORlines.- Re-run the CI job and confirm the
[ERROR] COMPILATION ERRORline is absent.
Why it matters
Java compilation errors block every downstream step — tests, packaging, and deployment all fail immediately. The errors are deterministic: the same code will fail every time until the source is corrected. Maven prints the compiler output verbosely enough to diagnose the exact file and line number, but the signal can be buried in pages of download progress output.
Prevention
- Run
mvn clean test-compilein a pre-merge CI step to catch compile errors before the full build. - Use a separate
generate-sourcesverification step if your project relies on annotation processors so broken generated code is caught early. - Avoid committing files under
target/generated-sources— let Maven regenerate them on every build.
Try it locally
mvn clean test-compile
mvn clean compile
mvn clean test-compile
How Faultline detects it
Use faultline explain maven-compile-error to see the full playbook.
faultline analyze build.log
faultline explain maven-compile-error
Generated from playbooks/bundled/log/build/maven-compile-error.yaml. Do not edit directly.