-
Notifications
You must be signed in to change notification settings - Fork 19
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
Validation doesn't work on OpenLiberty #293
Comments
Hi @mthmulders, I could imagine the Also I'll have a deeper look on your example later. Thanks for providing it! |
I've tried again, this time with curl 'http://localhost:9080/openliberty-mvc-validation/form/process' -X POST \
-H 'Accept: text/html' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'age=' And it gives an empty response ( |
Thanks for testing this. I'll have a look into that. Unfortunately RESTEasy seems to work differently on OpenLiberty than in WildFly, so I have no clue what the problem could be. |
Yes, I have noticed that before... If there's anything I could be of help with, please let me know. |
@mthmulders What you are seeing in your reproducer project is actually the default behavior for JAX-RS when Bean Validation is provided by the runtime. In this case, requests are validated before the resource method is invoked and in case of validation errors, the request is aborted. This behavior definitely makes sense for plain JAX-RS. As MVC requires a different behavior (controllers should always be invoked, regardless of whether a validation error occurred), Krazo has to use some "dirty" tricks. Especially, Krazo tries to veto the default CDI interceptor, which implements the behavior described above for all MVC controllers. The interesting part of the code starts here: krazo/core/src/main/java/org/eclipse/krazo/cdi/types/AnnotatedTypeProcessor.java Lines 75 to 87 in 73ebb27
If removing the CDI interceptor of bean validation does not work for some reason, you will get a behavior exactly like the one you are getting. Therefore, my guess is that our code needs some more adjustments to work correctly for Open Liberty. |
Thanks for the intro, @chkal. I've studied the Krazo code a bit and from what I understand, the code you've highlighted adds two annotations to existing controller methods:
The interesting thing I've observed is that for a GET request, first the |
Trying to build an application with Krazo on Jakarta EE 9, targeted to run on OpenLiberty. I'm using OpenLiberty 22.0.0.4, Krazo 2.0.1 (with the
LibertyHttpCommunicationUnwrapper
manually copied in).The Controller that should process the form is a literal copy of the example in the MVC 2.0 spec.
I submit the form from the browser, but for convenience, this is the raw request:
When I submit the form, I expect the Controller to be invoked, causing a) a log message to appear and b) hello.jsp to be rendered.
Instead, I get an XML response (formatted for reading convenience, the original response is unformatted):
The good part is that the validation rules are applied to the input. The bad part is that the Controller is not invoked, and the user is seeing XML in their browser.
Please let me know if there's something I missed in the spec, something else I could try, or some additional information you might need.
Links:
mvn liberty:dev
.The text was updated successfully, but these errors were encountered: