apache/maven · error · ArtifactNotFoundException
System artifact: {} is not a file: {}
Error message
System artifact: {} is not a file: {} What it means
The third system-scope check in resolve(): File.exists() passed but File.isFile() is false, meaning the systemPath resolves to a directory (or a symlink to one). Maven cannot place a directory on the classpath for a system dependency, so it throws ArtifactNotFoundException 'is not a file' with the offending path.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java:168
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()) {
ArtifactResult result;
try {
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(RepositoryUtils.toArtifact(artifact));
artifactRequest.setRepositories(RepositoryUtils.toRepos(remoteRepositories));
// Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
LocalRepositoryManager lrm = session.getLocalRepositoryManager();View on GitHub (pinned to e4093d4e12)
Solutions
- Point systemPath at the jar file itself, e.g. ${project.basedir}/lib/ojdbc8.jar, not the lib directory
- Remove trailing slashes or separators from the systemPath value
- Verify with ls -l using the exact path from the message, then re-run the build
Example fix
<!-- before: systemPath is a directory -->
<systemPath>${project.basedir}/lib/</systemPath>
<!-- after: point at the jar file inside it -->
<systemPath>${project.basedir}/lib/ojdbc8.jar</systemPath> Defensive patterns
Strategy: validation
Validate before calling
File f = artifact.getFile();
if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())
&& f != null && f.exists() && !f.isFile()) {
// systemPath resolves to a directory: point it at the jar file
} Type guard
private static boolean systemPathIsDirectory(org.apache.maven.artifact.Artifact a) {
return a != null && Artifact.SCOPE_SYSTEM.equals(a.getScope())
&& a.getFile() != null
&& a.getFile().exists()
&& !a.getFile().isFile();
} Try / catch
Catch ArtifactNotFoundException; when the message says 'is not a file', correct the systemPath to reference the jar file (not a directory) and re-run.
Prevention
- Treat systemPath values ending in a separator as a build-breaking smell in review.
- Prefer regular dependencies over system scope; jars under the project can go into a project-local repository instead.
When it happens
Trigger: A <systemPath> that resolves to a directory: pointing at a lib/ folder instead of the jar inside it, a path with a trailing separator, or a symlink chain that ends at a directory.
Common situations: Writing <systemPath>${project.basedir}/lib</systemPath> instead of lib/foo.jar; paths assembled by string concatenation that lose the file name; directory symlinks after moving a project.
Related errors
- System artifact: {} has no file attached
- System artifact: {} not found in path: {}
- Error copying POM to the local repository.
- Non-existing JDK home configuration at " + normal.toAbsolute
- Directory {} extracted from the -f/--file command-line argum
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/33b2df7ac2e04636.
Report an issue: GitHub.