apache/maven · error · IllegalStateException
ExtensionContext must not be null
Error message
ExtensionContext must not be null
What it means
Error "ExtensionContext must not be null" thrown in apache/maven.
Source
Thrown at impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java:103
/**
* Retrieves the extension context for the current thread.
*
* @return The extension context, or an empty Optional if not set
*/
protected static Optional<ExtensionContext> getContext() {
return Optional.ofNullable(EXTENSION_CONTEXT_THREAD_LOCAL.get());
}
/**
* Creates and configures the DI container for test execution.
* Performs component discovery and sets up basic bindings.
*
* @throws IllegalStateException if the ExtensionContext is null, the required test class is unavailable,
* the required test instance is unavailable, or if container setup fails
*/
protected Injector setupContainer(ExtensionContext context) {
if (context == null) {
throw new IllegalStateException("ExtensionContext must not be null");
}
final Class<?> testClass = context.getRequiredTestClass();
if (testClass == null) {
throw new IllegalStateException("Required test class is not available in ExtensionContext");
}
final Object testInstance = context.getRequiredTestInstance();
if (testInstance == null) {
throw new IllegalStateException("Required test instance is not available in ExtensionContext");
}
try {
Injector injector = Injector.create();
injector.bindInstance(ExtensionContext.class, context);
injector.discover(testClass.getClassLoader());
injector.bindInstance(Injector.class, injector);
injector.bindInstance(testClass.asSubclass(Object.class), (Object) testInstance); // Safe generics handling
return injector;
} catch (final Exception e) {View on GitHub (pinned to e4093d4e12)
When it happens
Trigger: Thrown at impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java:103 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/82b510e8339e87c7.
Report an issue: GitHub.