Issue
I am running a Micronaut CLI application via Picocli runner wanted to use applicationContext for injecting/getting the bean during application execution.
@HttpRetryable
@Client("SERVICE_ID")
interface TestHttpClient {
}
@Inject
lateinit var applicationContext: ApplicationContext
private class AuthenticationFilter() : HttpClientFilter {
// calling appcontext here
println("appContext is Running " + appContext.isRunning)
}
But getting this error on the execution
kotlin.UninitializedPropertyAccessException: lateinit property applicationContext has not been initialized```
How this can be fixed ?
Solution
The property needs to be in the AuthenticationFilter class. That class should be annotated with jakarta.inject.Singleton and should not be private
Answered By - James Kleeh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.