apache/maven · error · ArtifactNotFoundException
System artifact: {} has no file attached
Error message
System artifact: {} has no file attached What it means
DefaultArtifactResolver.resolve() shortcuts artifacts with scope 'system': no repository lookup happens, Maven uses only the file attached to the artifact (populated from <systemPath>). If that file is null, resolution fails immediately with ArtifactNotFoundException 'has no file attached'. It is a POM declaration error: the dependency declares system scope but no usable systemPath.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java:159
@Override
public void resolveAlways(
Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository)
throws ArtifactResolutionException, ArtifactNotFoundException {
resolve(artifact, remoteRepositories, getSession(localRepository));
}
private void resolve(
Artifact artifact, List<ArtifactRepository> remoteRepositories, RepositorySystemSession session)
throws ArtifactResolutionException, ArtifactNotFoundException {
if (artifact == null) {
return;
}
if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
File systemFile = artifact.getFile();
if (systemFile == null) {
throw new ArtifactNotFoundException("System artifact: " + artifact + " has no file attached", artifact);
}
if (!systemFile.exists()) {
throw new ArtifactNotFoundException(
"System artifact: " + artifact + " not found in path: " + systemFile, artifact);
}
if (!systemFile.isFile()) {
throw new ArtifactNotFoundException(
"System artifact: " + artifact + " is not a file: " + systemFile, artifact);
}
artifact.setResolved(true);
return;
}
if (!artifact.isResolved()) {View on GitHub (pinned to e4093d4e12)
Solutions
- Add or fix the <systemPath> element on the system-scoped dependency so it points at the jar
- Verify any property used in systemPath resolves in the running build: mvn help:evaluate -Dexpression=<prop>
- Prefer replacing the system-scope dependency with a normal one (mvn install:install-file into the repository or a project-local repo) - system scope is deprecated precisely because it bypasses resolution
Example fix
<!-- before: system scope without a systemPath -->
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
</dependency>
<!-- after: valid systemPath (or drop system scope entirely) -->
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency> Defensive patterns
Strategy: validation
Validate before calling
if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope()) && artifact.getFile() == null) {
// reject before resolve(): the POM lacks a usable <systemPath>
throw new IllegalArgumentException(
"system-scoped dependency " + artifact + " has no <systemPath>");
} Type guard
private static boolean isUnattachedSystemArtifact(org.apache.maven.artifact.Artifact a) {
return a != null
&& Artifact.SCOPE_SYSTEM.equals(a.getScope())
&& a.getFile() == null; // will fail resolution with 'no file attached'
} Try / catch
Catch ArtifactNotFoundException; if the message says 'has no file attached', the fix is in the POM (add systemPath or drop system scope), not in repositories or retries.
Prevention
- Avoid system scope; install the jar or serve it from a project repository instead.
- When systemPath is unavoidable, derive it from ${java.home} or ${project.basedir} and assert the property resolves.
- Inspect mvn help:effective-pom to see the final systemPath before building.
When it happens
Trigger: Resolving a dependency declared with <scope>system</scope> whose <systemPath> is absent, empty, or whose property placeholder resolves to nothing at the time DefaultArtifactResolver.resolve(...) runs.
Common situations: Copy-pasted system-scope dependencies where systemPath was dropped; systemPath driven by a property defined in a profile that is not active in the current build; ${java.home}-derived paths after a JDK layout change.
Related errors
- System artifact: {} not found in path: {}
- System artifact: {} is not a file: {}
- Repository list contains duplicate entries. Each repository
- Repository list contains null entries. All repository entrie
- A dependency has introduced a cycle
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/8e85f4e9431ddfb2.
Report an issue: GitHub.