apache/maven · error · ExpressionEvaluationException
Error evaluating plugin parameter expression: ${expression}
Error message
Error evaluating plugin parameter expression: ${expression} What it means
While injecting configuration into a mojo, Maven evaluated a plugin parameter expression rooted at the session object (for example ${session.localRepository.path}) via ReflectionValueExtractor, and the reflective walk threw. Maven wraps the failure in ExpressionEvaluationException carrying the exact expression, which then surfaces as a mojo configuration failure.
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java:191
try {
int pathSeparator = expression.indexOf('/');
if (pathSeparator > 0) {
String pathExpression = expression.substring(0, pathSeparator);
value = ReflectionValueExtractor.evaluate(pathExpression, session);
if (pathSeparator < expression.length() - 1) {
if (value instanceof Path path) {
value = path.resolve(expression.substring(pathSeparator + 1));
} else {
value = value + expression.substring(pathSeparator);
}
}
} else {
value = ReflectionValueExtractor.evaluate(expression, session);
}
} catch (Exception e) {
// TODO don't catch exception
throw new ExpressionEvaluationException(
"Error evaluating plugin parameter expression: " + expression, e);
}
} else if ("reactorProjects".equals(expression)) {
value = session.getProjects();
} else if ("project".equals(expression)) {
value = project;
} else if ("executedProject".equals(expression)) {
value = project.getExecutionProject();
} else if (expression.startsWith("project") || expression.startsWith("pom")) {
try {
int pathSeparator = expression.indexOf('/');
if (pathSeparator > 0) {
String pathExpression = expression.substring(0, pathSeparator);
value = ReflectionValueExtractor.evaluate(pathExpression, project);
value = value + expression.substring(pathSeparator);
} else {
value = ReflectionValueExtractor.evaluate(expression, project);View on GitHub (pinned to e4093d4e12)
Solutions
- Test the expression standalone: mvn help:evaluate -Dexpression=session.localRepository.path -q -DforceStdout.
- Compare the path against the MavenSession getters (getLocalRepository, getSettings, getTopLevelProject, ...) and fix the segment names.
- If an intermediate value can be null, split the expression or provide a default through a property in <properties>.
- Prefer plain project properties over deep session reflection paths.
Example fix
<!-- before -->
<repoDir>${session.localRepo.path}</repoDir>
<!-- after: match the real MavenSession getter chain -->
<repoDir>${session.localRepository.path}</repoDir> Defensive patterns
Strategy: validation
Validate before calling
mvn -q org.apache.maven.plugins:maven-help-plugin:3.4.1:evaluate \ -Dexpression=session.localRepository.path -DforceStdout || echo 'BAD EXPRESSION'
Try / catch
try {
configValue = evaluator.evaluate(expr, Object.class);
} catch (ExpressionEvaluationException e) {
throw new MojoExecutionException("unresolvable expression: " + e.getMessage(), e);
} Prevention
- Lint plugin configurations for session.* expressions against MavenSession getters
- Verify expressions with help:evaluate during POM review
- Avoid deep nested paths; bind intermediate values into <properties>
When it happens
Trigger: An expression like ${session.someField} where someField is not a readable property of MavenSession; a nested path that traverses a null intermediate (a getter returns null and the next segment is dereferenced); malformed path segments with stray characters.
Common situations: Typos in POM configuration values; expressions that worked under an older Maven where session getters differed; templates copied from other projects that reference session state which is null in the current phase.
Related errors
- Cannot find default setter in {}
- Cannot set default
- Error evaluating plugin parameter expression: ${expression}
- Failed to interpolate field: " + field + " on class: " + cls
- The token '%s' at position '%d' refers to a java.util.Map, b
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/1b53b878c56ce6b5.
Report an issue: GitHub.