Skip to content

Windows AccessDeniedException on install when IDE holds the jar open (Maven 3.10.0 regression) #2204

Open

Description

@gnodet

Problem

Maven 3.10.0 introduced a regression on Windows where mvn install fails with java.nio.file.AccessDeniedException when an IDE (e.g. IntelliJ IDEA) has the target artifact .jar open.

Reported upstream: apache/maven#13329

Root Cause

Resolver PR #2083 (commit a7104fab) replaced the old stream-based file copy with Files.move() + ATOMIC_MOVE in PathProcessorSupport.retryingMove() to fix the f007 security finding (non-atomic Windows publication).

The old code used classicCopy()\ which opens the target with a truncating FileOutputStream. On Windows, this succeeds even when another process has the file open for reading, because the stream open uses FILE_SHARE_READ` semantics.

The new code uses Files.move() which maps to MoveFileEx/ReplaceFile on Windows. These system calls require exclusive access to the destination — any open handle (including a shared read-only handle from an IDE) causes AccessDeniedException. With only 5 retries at 50 ms each, persistent IDE locks are never released.

Fix

After exhausting all WINDOWS_MOVE_ATTEMPTS with AccessDeniedException, fall back to classicCopy() directly to the target as a last resort. A system property controls the fallback.

Reported and analyzed by Hermès Agent on behalf of Guillaume Nodet

Activity

  1. slachiewicz commented on Oct 13, 2026

    @slachiewicz
    Member

    Another trigger for the same move failure, from CI rather than an IDE: two parallel invoker ITs sharing one local repository on windows-latest. One IT process has plexus-utils-3.6.0.jar loaded in its plugin class loader while the other moves plexus-utils-3.6.0.jar.<n>.tmp over it, and the build fails with AccessDeniedException ("Could not transfer artifact org.codehaus.plexus:plexus-utils:jar:3.6.0 ... .tmp -> ...plexus-utils-3.6.0.jar"). It happens with Maven 3.10.0 (resolver 2.0.24) and 4.0.0-rc-7 (resolver 2.0.23), with FileLockNamedLockFactory active, and not with 3.9.x. Four of the last mojohaus/build-helper-maven-plugin master runs failed this way, for example https://github.com/mojohaus/build-helper-maven-plugin/actions/runs/38377940557. The fallback in #2205 should cover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions