Open wmunyan opened 1 year ago
Your example application doesn't have any classes
@dstepanov Sorry about that - There should be code there now
I've been playing with this a little bit and found an interesting bit of info... If I try to use:
@Inject
HeartbeatService heartbeatService
The code fails and the service fails to inject. However, if I use Constructor injection:
final HeartbeatService heartbeatService
HeartbeatController(HeartbeatService heartbeatService) {
this.heartbeatService = heartbeatService
}
... the injection works and the test passes. Is there something within the @Endpoint
annotation that has changed from Micronaut 3 to 4 that doesn't allow field-level injection anymore?
Another small update on this; I recreated the project in Java (and not Groovy) and the @Inject
method works as expected, so perhaps this issue is Groovy-related with the @Endpoint
annotation?
looks like this happens because @Endpoint
is annotated with @ConfigurationReader
– why is that @graemerocher ?
Issue description
The Issue
I have a groovy project using Micronaut 4.0.6 and I have annotated a class with
@Endpoint
, but then I cannot@Inject
a dependency, it throws aNullPointerException
Expected Behavior
Dependency Injection should work
Actual Behavior
The
null
object is the Service class that is supposed to be@Inject
edSteps to Reproduce
Run the example application at https://github.com/wmunyan/heartbeat
NOTE: When I replace the
@Endpoint
annotation and just make the class a regular@Controller
, the dependency injection works fine.Environment
Windows 10 Java 17 Groovy 4 Micronaut 4.0.6 (created via micronaut launch)
Example Application
https://github.com/wmunyan/heartbeat
NOTE: Submitting a "Bug Report" doesn't seem to be allowed for me. I click the button, it turns disabled, but doesn't do anything nor does it navigate away from the page, and it isn't obvious that anything is wrong with the data I entered.