-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Context injection when CDI is enabled and @DisableDiscovery is specified does not work #4493
Comments
Injecting HttpHeaders in ExceptionMapper also does not work properly when running test with @HelidonTest, @DisableDiscovery and CDI extensions included, in particular case the the HttpHeaders are injected but when calling getRequestHeaders() an exception is thrown(see below). Injecting HttpHeaders in ExceptionMapper works properly when application in running.
|
I have verified that this is indeed the case. For some reason, the bean is known to CDI (via |
(My blind guess here is that some Jersey-to-CDI integration nugget is not added via |
@ljnelson Test adds a few extensions by hand, but perhaps the list is incomplete, not sure. Regular |
The problem came from the exception mapper beeing registered twice - once through CDI as a bean ( @HelidonTest(resetPerTest = true)
@DisableDiscovery
@AddExtension(ServerCdiExtension.class)
@AddExtension(JaxRsCdiExtension.class)
@AddExtension(CdiComponentProvider.class)
@AddBean(HelloWorldApplication.class) (removed JAX-RS resource and exception mapper, added JAX-RS application) You may also consider adding ConfigCdiExtension. |
I will close this issue, as the provided solution works without issues (tried with reproducer). |
Environment Details
Problem Description
Injecting UriInfo with @context in an ExceptionMapper works when the Helidon application is running but when running unit test cases for the ExceptionMapper with @HelidonTest, the UriInfo does not get injected. Our test classes have @DisableDiscovery and CDI extensions included.
Steps to reproduce
Use attached reproducible project to recreate the issue. When running the application, http://localhost:8080/greet/boom will trigger the exception and the UriInfo in the ExceptionMapper will be injected, when the same scenario is run from the test, UriInfo is not injected
UriInfoReproducible.zip
The text was updated successfully, but these errors were encountered: