E08210: program uses injection but application has no registration for the required component type
What went wrong
A program uses component injection (via '!' suffix) but the linked application has no registration for the required abstract component type. Every injected component must have a concrete implementation registered.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 230 (What happens if I forget to register a dependency in EK9?)
- ek9 -q 798 (What happens with missing or duplicate component registra...)
- ek9 -q 227 (How does EK9 validate dependency injection at compile time?)
- ek9 -q 324 (What is the EK9 equivalent of Spring @Autowired?)
- ek9 -q 329 (How does EK9 DI compare to Google Guice modules?)
How to fix it
- Add the missing registration to the application block
- Or remove the injection if the dependency is not needed
- Check that the abstract type name matches exactly
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E08210: program uses injection but application has no registration for the required component type
#!ek9 defines module error.e08210.bad defines component AbstractA as abstract doWorkA() as abstract <- rtn as Boolean? default operator ? AbstractB as abstract doWorkB() as abstract <- rtn as Boolean? default operator ? ComponentA is AbstractA svcB as AbstractB! override doWorkA() <- rtn as Boolean: true default operator ? ComponentB is AbstractB override doWorkB() <- rtn as Boolean: true default operator ? defines application missingApp register ComponentA() as AbstractA
Fixed: Register a component for every abstract one that is injected - before the one it is injected into
#!ek9 defines module error.e08210.good.fix defines component AbstractA as abstract doWorkA() as abstract <- rtn as Boolean? default operator ? AbstractB as abstract doWorkB() as abstract <- rtn as Boolean? default operator ? ComponentA is AbstractA svcB as AbstractB! override doWorkA() <- rtn as Boolean: true default operator ? ComponentB is AbstractB override doWorkB() <- rtn as Boolean: true default operator ? defines application missingApp register ComponentB() as AbstractB register ComponentA() as AbstractA
Fixed: Register every component that is injected
#!ek9 defines module error.e08210.good defines component AbstractA as abstract doWorkA() as abstract <- rtn as Boolean? default operator ? AbstractB as abstract doWorkB() as abstract <- rtn as Boolean? default operator ? ComponentB is AbstractB override doWorkB() <- rtn as Boolean: true default operator ? ComponentA is AbstractA svcB as AbstractB! override doWorkA() <- rtn as Boolean: svcB.doWorkB() default operator ? defines application completeApp register ComponentB() as AbstractB register ComponentA() as AbstractA
Questions and answers
These Q&A entries show E08210 and its fix:
- Q227: How does EK9 validate dependency injection at compile time?
- Q230: What happens if I forget to register a dependency in EK9?
- Q324: What is the EK9 equivalent of Spring @Autowired?
- Q329: How does EK9 DI compare to Google Guice modules?
- Q673: What happens when a component is injected but not registered?
- Q675: How does EK9 validate transitive component dependencies?
- Q691: How does EK9 validate DI component registration and dependency ordering?
- Q798: What happens with missing or duplicate component registrations?
- Q1110: Register a Logger service and inject it into a program.
- Q1114: Wire an application with all dependencies correctly to pass compile-time DI validation.