apache/maven · error · IllegalStateException

Failed to set up DI injector for test class '%s': %s

Error message

Failed to set up DI injector for test class '%s': %s

What it means

Error "Failed to set up DI injector for test class '%s': %s" thrown in apache/maven.

Source

Thrown at impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java:122

        }
        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) {
            throw new IllegalStateException(
                    String.format(
                            "Failed to set up DI injector for test class '%s': %s",
                            testClass.getName(), e.getMessage()),
                    e);
        }
    }

    /**
     * Cleans up resources after each test method execution.
     * Currently a placeholder for future cleanup implementation.
     *
     * @param context The extension context provided by JUnit
     */
    @Override
    public void afterEach(ExtensionContext context) throws Exception {
        try {
            Injector injector = context.getStore(MAVEN_DI_EXTENSION).get(Injector.class, Injector.class);
            if (injector != null) {

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:122 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/c987097269f5b05a. Report an issue: GitHub.