{"record":{"id":"c987097269f5b05a","repo":"apache/maven","slug":"failed-to-set-up-di-injector-for-test-class-s","errorCode":null,"errorMessage":"Failed to set up DI injector for test class '%s': %s","messagePattern":"Failed to set up DI injector for test class '(.+?)': (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java","lineNumber":122,"sourceCode":"        }\n        final Class<?> testClass = context.getRequiredTestClass();\n        if (testClass == null) {\n            throw new IllegalStateException(\"Required test class is not available in ExtensionContext\");\n        }\n        final Object testInstance = context.getRequiredTestInstance();\n        if (testInstance == null) {\n            throw new IllegalStateException(\"Required test instance is not available in ExtensionContext\");\n        }\n\n        try {\n            Injector injector = Injector.create();\n            injector.bindInstance(ExtensionContext.class, context);\n            injector.discover(testClass.getClassLoader());\n            injector.bindInstance(Injector.class, injector);\n            injector.bindInstance(testClass.asSubclass(Object.class), (Object) testInstance); // Safe generics handling\n            return injector;\n        } catch (final Exception e) {\n            throw new IllegalStateException(\n                    String.format(\n                            \"Failed to set up DI injector for test class '%s': %s\",\n                            testClass.getName(), e.getMessage()),\n                    e);\n        }\n    }\n\n    /**\n     * Cleans up resources after each test method execution.\n     * Currently a placeholder for future cleanup implementation.\n     *\n     * @param context The extension context provided by JUnit\n     */\n    @Override\n    public void afterEach(ExtensionContext context) throws Exception {\n        try {\n            Injector injector = context.getStore(MAVEN_DI_EXTENSION).get(Injector.class, Injector.class);\n            if (injector != null) {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java#L104-L140","documentation":"Error \"Failed to set up DI injector for test class '%s': %s\" thrown in apache/maven.","triggerScenarios":"Thrown at impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}