Diagnosing Stale Resources and Phantom Errors in Eclipse Incremental Builds
A step‑by‑step diagnostic guide for Eclipse incremental build problems: stale resources, phantom errors, and project sync failures. Covers refresh policy, builder state, linked resources, builder order, and Maven/Gradle nature mismatches with concrete fixes and escalation criteria.
10 Dec 2025, 01:10 UTC

Recognizable Condition
The Problems view shows compilation errors on files that build cleanly from the command line (mvn compile or ./gradlew classes). After an external operation such as git checkout, npm install, or a code generator run, you may also see the marker Resource is out of sync with the file system.
Root Cause Taxonomy
| Category | Typical Symptom | Underlying Mechanism |
|---|---|---|
| Workspace refresh disabled | Errors disappear after manual F5 refresh | Preferences → General → Workspace → Refresh using native hooks or polling unchecked |
| Incremental builder state corruption | Phantom errors persist across clean builds | Stale .markers or .syncinfo files in .metadata/.plugins/org.eclipse.core.resources/.projects/<proj>/ |
| Linked resources / path variables | Project works for one user, fails for another | Path variables resolve differently after OS or user switch |
| Builder order conflict | Annotation‑processor generated sources not found | Java Builder runs before the code‑gen builder that creates generated-sources |
| Gradle/Maven nature mismatch | Buildship or m2eclipse reports missing plugins | Wrapper version out of sync with the IDE plug‑in (Buildship 3.x, m2eclipse 2.x) |
Ordered Diagnostic Checks
- Manual refresh – Select the project and press F5 (or File → Refresh). If errors vanish, the refresh policy is the culprit.
- Clean without immediate rebuild – Project → Clean…, uncheck Start a build immediately, then toggle Build Automatically off and on. This forces a fresh incremental state.
- Compare project metadata – Open
.classpathand.projectside‑by‑side with the VCS HEAD. Look for missing source folders, duplicate entries, or outdatedclasspathentrykinds. - Inspect the Error Log – Window → Show View → Error Log. Filter for
Resource is out of syncor stack traces fromorg.eclipse.core.internal.resources. - External clean build – Run
mvn clean compileor./gradlew classesin a terminal (same workspace root). If the external build succeeds, the Eclipse model has drifted.
Fixes Mapped to Findings
Refresh Policy
- Enable native hooks: Preferences → General → Workspace → Refresh using native hooks or polling (check). On network‑mounted workspaces (NFS/SMB) prefer Polling with a 2–5 s interval to avoid high CPU.
- Alternatively, add a
refreshgoal to your Maven/Gradle launch configuration so the workspace refreshes automatically after each external build.
Builder State Corruption
- Close the affected project (Project → Close Project). Delete
.metadata/.plugins/org.eclipse.core.resources/.projects/<proj>/.markersand.syncinfo. Reopen the project and let Eclipse rebuild. - Risk: Deleting these files while the project is open can corrupt the workspace. Always close first.
Linked Resources / Path Variables
- Define shared path variables in Preferences → General → Workspace → Linked Resources (e.g.,
PROJECT_ROOT). Use${project_loc}for project‑relative paths.
Builder Order
- Open Project → Properties → Builders. Move the code‑gen builder (e.g., Annotation Processing or a custom Ant/Maven builder) above the Java Builder so generated sources exist before compilation.
Nature Mismatch (Maven/Gradle)
- Maven: Right‑click project → Maven → Update Project…, check Force update of snapshots/releases.
- Gradle: Right‑click project → Gradle → Refresh Gradle Project, enable Force update of snapshots/releases.
- If Gradle daemon is stale (common with Buildship 3.x+), run
./gradlew --stopin a terminal before refreshing. - Verify wrapper version:
.mvn/wrapper/maven-wrapper.propertiesmust specify Maven 3.8+ for m2eclipse 2.x.
Escalation Criteria
- Clean + refresh + builder reorder fails after two full cycles.
- Error Log shows recurring
java.lang.IllegalStateException: Zip file closedor repeatedResource out of syncentries fromorg.eclipse.core.internal.resources. - Multiple developers encounter the same issue after a shared
.project/.classpathcommit → file a bug against Buildship or m2eclipse, attaching the workspace.log(Help → About Eclipse IDE → Installation Details → Configuration).
Limitations & Practical Verification
These steps cover the most common drift scenarios for Eclipse 2023‑09 through 2024‑12 releases. They do not address:
- Custom builder plug‑ins that maintain their own state outside
.markers. - Workspace corruption caused by simultaneous Eclipse instances on the same metadata directory.
Verification checklist (run after each fix):
- Create a minimal Java project with an annotation processor that writes to
target/generated-sources/annotations. - Disable auto‑refresh, run
mvn generate-sourcesexternally, confirm the stale‑resource marker appears. - Toggle Refresh using native hooks or polling and verify that F5 behavior changes accordingly.
- Inspect
.markersbefore and after Project → Clean to confirm marker clearance. - After a
git checkoutthat modifies.classpath, check the Error Log fororg.eclipse.core.internal.resourcesentries. - Run
./gradlew --stopthen Refresh Gradle Project to confirm daemon‑related stale state resolves.
If all checks pass, the workspace should stay in sync with the file system and external builds.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.