{"record":{"id":"6d81e9f0bd31bc1d","repo":"apache/maven","slug":"no-binding-to-construct-an-instance-for-key-e","errorCode":null,"errorMessage":"No binding to construct an instance for key {}.  Existing bindings:\n - {}","messagePattern":"No binding to construct an instance for key (.+?)\\.  Existing bindings:\n - (.+?)","errorType":"exception","errorClass":"DIException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/internal/impl/SisuDiBridgeModule.java","lineNumber":196,"sourceCode":"\n        private <Q> Supplier<Q> getBeanSupplier(Dependency<Q> dep, Key<Q> key) {\n            List<Binding<?>> list = new ArrayList<>();\n            // Add DI bindings\n            list.addAll(getBindings().getOrDefault(key, Set.of()));\n            // Add Plexus bindings\n            for (var bean : locator.get().locate(toGuiceKey(key))) {\n                if (isPlexusBean(bean)) {\n                    list.add(new BindingToBeanEntry<>(key).toBeanEntry(bean).prioritize(bean.getRank()));\n                }\n            }\n            if (!list.isEmpty()) {\n                list.sort(getPriorityComparator());\n                //noinspection unchecked\n                return () -> (Q) getInstance(list.iterator().next());\n            } else if (dep.optional()) {\n                return () -> null;\n            } else {\n                throw new DIException(\"No binding to construct an instance for key \"\n                        + key.getDisplayString() + \".  Existing bindings:\\n\"\n                        + getBoundKeys().stream()\n                                .map(Key::toString)\n                                .map(String::trim)\n                                .sorted()\n                                .distinct()\n                                .collect(Collectors.joining(\"\\n - \", \" - \", \"\")));\n            }\n        }\n\n        @Override\n        public <T> Set<Binding<T>> getAllBindings(Class<T> clazz) {\n            Key<T> key = Key.of(clazz);\n            Set<Binding<T>> bindings = new HashSet<>();\n            Set<Binding<T>> diBindings = super.getBindings(key);\n            if (diBindings != null) {\n                bindings.addAll(diBindings);\n            }","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/internal/impl/SisuDiBridgeModule.java#L178-L214","documentation":"A dependency-injection failure from the Sisu-to-consumer-API bridge: code asked the DI container for a component at a given key (type plus qualifier), no Plexus/Sisu bean matched, and the injection point was not optional. The message helpfully lists every key that IS bound, so you can see what the container knows about versus what you requested.","triggerScenarios":"Calling session.getService(SomeService.class) (or injecting a qualified component) where no implementation of SomeService is registered; requesting a @Named-qualified component whose qualifier string does not match any @Named annotation on implementations; a plugin missing a META-INF/sisitu/javax.inject.Named file so its components are never indexed.","commonSituations":"Using a maven-api service interface inside a plugin without depending on the module that provides its default implementation; upgrading Maven where a service moved packages or got renamed; classpath shading or duplicate plugin jars hiding the component; qualifier typo such as @Named(\"mvn\") vs @Named(\"maven\").","solutions":["Compare your requested key with the 'Existing bindings' list printed in the message — usually the type or qualifier is spelled differently","Add the dependency that contains the default implementation of the service (e.g. maven-core's impl artifact) to your plugin/embedder classpath","If you wrote the component, annotate it with @Named/@Singleton and ensure META-INF/sisitu index generation runs (sisu-maven-plugin)","For optional lookups, use the API variant that supports optional dependencies instead of a hard lookup"],"exampleFix":"// before\nWorkspaceReader reader = session.getService(WorkspaceReader.class); // DIException: no binding\n\n// after\n// add the artifact that provides the default component, e.g. in plugin dependencies:\n<dependency>\n  <groupId>org.apache.maven</groupId>\n  <artifactId>maven-core</artifactId>\n  <scope>provided</scope>\n</dependency>","handlingStrategy":"validation","validationCode":"// before a hard service lookup, verify a binding exists\ntry {\n    T service = session.getService(type); // throws DIException if unbound\n} catch (DIException e) {\n    LOG.warn(\"Service not available: {}\", type.getName());\n}","typeGuard":null,"tryCatchPattern":"catch (org.apache.maven.api.di.DiException | org.eclipse.sisu.InjectionException e) {\n    // inspect message: 'Existing bindings' list tells you what the container offers\n    throw new IllegalStateException(\"Missing DI binding for \" + type, e);\n}","preventionTips":["Depend on the artifacts that provide default service implementations (maven-core impl) with provided scope","Prefer constructor injection over manual getService lookups — wiring problems surface at startup","When requesting qualified components, double-check @Named strings against the provider"],"tags":["maven","dependency-injection","sisu","service-lookup","class-path"],"backgroundTag":"di-no-binding-for-key","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}