apache/maven · error · PrompterException

Unable to promptForPassword

Error message

Unable to promptForPassword

What it means

Thrown when a masked password prompt fails. LegacyPlexusInteractivity.promptForPassword(message) delegates to prompter.promptForPassword and wraps any org.apache.maven.api.services.PrompterException in the legacy PrompterException with message 'Unable to promptForPassword'. Like the other prompt methods, the root cause is console/stdin unavailability or an I/O failure during the secure read.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/internal/compat/interactivity/LegacyPlexusInteractivity.java:138

            throw new PrompterException("Unable to prompt", e);
        }
    }

    @Override
    public String prompt(String message, List possibleValues, String defaultReply) throws PrompterException {
        try {
            return prompter.prompt(message, possibleValues, defaultReply);
        } catch (org.apache.maven.api.services.PrompterException e) {
            throw new PrompterException("Unable to prompt", e);
        }
    }

    @Override
    public String promptForPassword(String message) throws PrompterException {
        try {
            return prompter.promptForPassword(message);
        } catch (org.apache.maven.api.services.PrompterException e) {
            throw new PrompterException("Unable to promptForPassword", e);
        }
    }

    @Override
    public void showMessage(String message) throws PrompterException {
        try {
            prompter.showMessage(message);
        } catch (org.apache.maven.api.services.PrompterException e) {
            throw new PrompterException("Unable to showMessage", e);
        }
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Supply credentials non-interactively: settings.xml <server> entries, ~/.m2 settings security, or environment variables instead of prompting
  2. Run in batch mode (-B) and ensure the build never reaches an interactive password prompt
  3. Catch PrompterException and fail with an actionable message telling the operator how to provide the credential
  4. If interactive entry is required, run from a real terminal with stdin open

Example fix

// before
String pwd = prompter.promptForPassword("Repository password:");
// after
String pwd;
try {
    pwd = prompter.promptForPassword("Repository password:");
} catch (PrompterException e) {
    pwd = System.getenv("REPO_PASSWORD"); // CI: read from env instead
    if (pwd == null) throw new IllegalStateException("No password source available", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean canPromptSecurely = System.console() != null; // Console is required for masked reads in most impls

Try / catch

try {
    return prompter.promptForPassword(message);
} catch (PrompterException e) {
    throw new IllegalStateException("Password prompt failed; set REPO_PASSWORD env var or configure settings.xml", e);
}

Prevention

When it happens

Trigger: Calling promptForPassword(message) when no console is attached, stdin hits EOF, or the underlying secure prompt implementation throws (e.g., Console.readLine returning null in a headless JVM).

Common situations: Legacy plugins asking for credentials (repository passwords, GPG passphrases) via the old Prompter inside CI; docker/daemonized Maven runs without a TTY; unattended builds reaching a credential prompt.

Related errors


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