Skip to content
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

Qaurkus Camel bean-validator throws javax.enterprise.context.ContextNotActiveException when quarkus-resteasy-reactive-jackson is present #23195

Closed
nikosk686 opened this issue Jan 25, 2022 · 4 comments · Fixed by #23201
Labels
area/jackson Issues related to Jackson (JSON library) area/rest kind/bug Something isn't working
Milestone

Comments

@nikosk686
Copy link

Describe the bug

Using camel bean-validator throws ContextNotActiveException when quarkus-resteasy-reactive-jackson dependency is also present and the provided bean is invalid based on the validation annotations.
Also with quarkus-resteasy-reactive-jackson the bean validator exception is of type javax.validation.ValidationException
while without this dependency the associated exception is of type org.apache.camel.ValidationException.
The issue is that in the first case and due to then ContextNotActiveException we cannot have a clue regarding the invalid fields.

Expected behavior

Bean validator should work without throwing ContextNotActiveException

Actual behavior

Bean validator throws ContextNotActiveException in case of an invalid bean.
The exact problem resides in then ResteasyReactiveContextLocaleResolver class and specifically in the following call:
headers.getLength();

How to Reproduce?

Reporducer: https://github.com/nikosk686/quarkus-camel-bean-validation-poc

running the test in the main branch where quarkus-resteasy-reactive-jackson is not present you can see that everything is working fine.
An org.apache.camel.ValidationException is being thrown as you can see in the console logs with the following message:

class org.apache.camel.component.bean.validator.BeanValidationException : Validation failed for: {"field":""} errors: [property: field; value: ; constraint: must not be blank; ]

But running the same test in the problem branch, you'll find out that a javax.validation.ValidationException is being thrown and the message is

class javax.validation.ValidationException : HV000149: An exception occurred during message interpolation : javax.enterprise.context.ContextNotActiveException

Output of uname -a or ver

Linux dell-desktop 5.10.0-1057-oem #61-Ubuntu SMP Thu Jan 13 15:06:11 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

corretto-11

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.3.3

Additional information

No response

@nikosk686 nikosk686 added the kind/bug Something isn't working label Jan 25, 2022
@quarkus-bot quarkus-bot bot added the area/jackson Issues related to Jackson (JSON library) label Jan 25, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 25, 2022

/cc @FroMage, @geoand, @gsmet, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jan 26, 2022

Hi,

I just executed the tests of the reproducer in the problem branch and everything passed.
Is there something the reproducer is missing?

@nikosk686
Copy link
Author

Hello @geoand
the test is passing in both branches as the assertion is trivial.
You can identfy the issue by examining the produced logs after each execution though, as I explained above.
thnx

@geoand
Copy link
Contributor

geoand commented Jan 26, 2022

#23201 takes care of the issue

geoand added a commit that referenced this issue Jan 27, 2022
Guard against ContextNotActiveException in ResteasyReactiveContextLocaleResolver
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Jan 27, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.1.Final Jan 31, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/jackson Issues related to Jackson (JSON library) area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants