E12021: program creates HTTP but application has no service registrations
What went wrong
The program creates an HTTP server instance, but the linked application has no service registrations. An HTTP server with no services has nothing to route requests to — every request would receive a 404 Not Found.
Worked examples
The [EXAMPLE] section below shows a program serving HTTP from an application that registers only components, then the application registering a service for it to route to.
Rationale
Creating an HTTP server with no services to bind is a structural error. The server would start, bind the port, and accept connections — but every request would fail because no routes exist. Catching this at compile time prevents wasted infrastructure and confusing runtime 404s.
How to fix it
Either:
- Add service registrations to the application (most likely fix), or
- Remove the HTTP instance from the program if HTTP serving is not needed.
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E12021: program creates HTTP but application has no service registrations
#!ek9 defines module error.e12021.bad defines component Logger as abstract doLog() <- rtn as String: "logged" default operator ? ConsoleLogger extends Logger default operator ? defines application LogApp register ConsoleLogger() as Logger defines program HttpWithoutServicesDemo() with application of LogApp props <- NetworkProperties(9090) HTTP(props).serve()
Fixed: Register a service in the application the HTTP server serves
#!ek9 defines module error.e12021.good defines service HelloService for :/api open health() as GET for :/status <- response as HTTPResponse: () with trait of HTTPResponse override status() as pure <- rtn as Integer: 200 override content() <- rtn as Bytes: Bytes().withUtf8("ok") override contentType() as pure <- rtn as String: "text/plain" default operator ? defines application HelloApp register HelloService() defines program HttpWithServicesDemo() with application of HelloApp props <- NetworkProperties(9090) HTTP(props).serve()