apache/maven · error · ProjectBuilderException

Unable to verify file existence for

Error message

Unable to verify file existence for '${glob}' inside '${fixedPath}'

What it means

When a profile activation file check uses a wildcard (e.g. exists('src/**/*.java') or a <file exists="dir/*.xml"/> tag), DefaultProfileActivationContext splits the pattern into a fixed directory plus a glob and walks the tree with Files.walkFileTree. Any IOException during the walk (permission denied, unreadable entry, IO error) is wrapped in ProjectBuilderException with this message.

Solutions

  1. Check permissions on the directory named in the message (ls -ld) and fix ownership/permission bits so the build user can traverse it
  2. Narrow the glob so it walks a small, readable subtree instead of the whole project
  3. Replace wildcard checks with a plain file path when a single well-known file is enough
  4. If the read-only environment is intentional, deactivate the profile (-P!profile) so activation never probes the tree

Example fix

<!-- before: walks the whole project tree -->
<condition>exists('${project.basedir}/**/Dockerfile')</condition>

<!-- after: single readable path (or a tight subtree) -->
<condition>exists('${project.basedir}/Dockerfile')</condition>
Defensive patterns

Strategy: validation

Validate before calling

static boolean canWalk(Path dir) {
    return Files.isDirectory(dir) && Files.isReadable(dir);
}
// before evaluating a glob condition
Path fixed = Path.of(pattern.substring(0, pattern.indexOf('*'))).getParent();
if (fixed != null && !canWalk(fixed)) {
    // treat the profile as not activatable instead of letting the walk fail
}

Try / catch

try {
    boolean active = profileActivationContext.exists(globPath, true);
} catch (ProjectBuilderException e) {
    // underlying IOException: unreadable/locked tree; decide activation policy explicitly
}

Prevention

When it happens

Trigger: An activation condition whose fixed prefix directory exists but cannot be traversed: missing read/execute permission, restrictive ACL, read-only or corrupted mount, broken symlinks, or entries deleted while the walk is in progress.

Common situations: Hardened CI containers running as non-root; Docker volumes with unexpected ownership; NFS/SMB mounts; huge trees walked in parallel with cleanup jobs removing files.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/ef4e15ce62e5a2b6. Report an issue: GitHub.

Appendix: source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileActivationContext.java:454

            return false;
        }
        if (glob != null && !glob.isEmpty()) {
            try {
                PathMatcher matcher = fixedPath.getFileSystem().getPathMatcher("glob:" + glob);
                AtomicBoolean found = new AtomicBoolean(false);
                Files.walkFileTree(fixedPath, new SimpleFileVisitor<>() {
                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
                        if (found.get() || matcher.matches(fixedPath.relativize(file))) {
                            found.set(true);
                            return FileVisitResult.TERMINATE;
                        }
                        return FileVisitResult.CONTINUE;
                    }
                });
                return found.get();
            } catch (IOException e) {
                throw new ProjectBuilderException(
                        "Unable to verify file existence for '" + glob + "' inside '" + fixedPath + "'", e);
            }
        }
        return true;
    }

    private static Map<String, String> unmodifiable(Map<String, String> map) {
        return map != null ? Collections.unmodifiableMap(map) : Collections.emptyMap();
    }
}

View on GitHub (pinned to e4093d4e12)