Problem
Plugins that use the deprecated PlexusContainer injection via MavenSession.lookup() get a NullPointerException in Maven 4 because this.container is null:
[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute
on project manual: java.lang.NullPointerException:
Cannot invoke "org.codehaus.plexus.PlexusContainer.lookup(String)"
because "this.container" is null
Stack trace:
at org.apache.maven.execution.MavenSession.lookup(MavenSession.java:477)
at org.codehaus.groovy.maven.plugin.execute.ExpressionEvaluatorImpl.lookupPathTranslator(...)
at org.codehaus.groovy.maven.plugin.execute.ExpressionEvaluatorImpl.<init>(...)
Affected project
servicemix — uses gmaven-plugin:1.0 which calls MavenSession.lookup() internally
Analysis
MavenSession.container was deprecated but still used by several plugins. In Maven 4, it appears the field is no longer populated. While the API is deprecated, the result is a hard NPE rather than a graceful deprecation warning.
Expected behavior
Either:
- Continue injecting the PlexusContainer into MavenSession for backward compatibility (with a deprecation warning)
- Or throw a descriptive exception (e.g.,
UnsupportedOperationException("PlexusContainer injection was removed in Maven 4. Use JSR 330 injection instead.")) rather than an NPE
Context
Data from maven4-testing run #13307 testing maven-4.0.x against all Apache projects.
Problem
Plugins that use the deprecated
PlexusContainerinjection viaMavenSession.lookup()get aNullPointerExceptionin Maven 4 becausethis.containeris null:Stack trace:
Affected project
servicemix— usesgmaven-plugin:1.0which callsMavenSession.lookup()internallyAnalysis
MavenSession.containerwas deprecated but still used by several plugins. In Maven 4, it appears the field is no longer populated. While the API is deprecated, the result is a hard NPE rather than a graceful deprecation warning.Expected behavior
Either:
UnsupportedOperationException("PlexusContainer injection was removed in Maven 4. Use JSR 330 injection instead.")) rather than an NPEContext
Data from maven4-testing run #13307 testing
maven-4.0.xagainst all Apache projects.