{"record":{"id":"67c837bf15f718ee","repo":"apache/maven","slug":"required-test-instance-is-not-available-in-extensi","errorCode":null,"errorMessage":"Required test instance is not available in ExtensionContext","messagePattern":"Required test instance is not available in ExtensionContext","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java","lineNumber":111,"sourceCode":"\n    /**\n     * Creates and configures the DI container for test execution.\n     * Performs component discovery and sets up basic bindings.\n     *\n     * @throws IllegalStateException if the ExtensionContext is null, the required test class is unavailable,\n     *         the required test instance is unavailable, or if container setup fails\n     */\n    protected Injector setupContainer(ExtensionContext context) {\n        if (context == null) {\n            throw new IllegalStateException(\"ExtensionContext must not be null\");\n        }\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","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java#L93-L129","documentation":"Error \"Required test instance is not available in ExtensionContext\" thrown in apache/maven.","triggerScenarios":"Thrown at impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java:111 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"}