eclipse-ee4j / eclipse-ee4j/krazo

Bean validation doesn't work on OpenLiberty

Open
#398 0 comments 0 reactions 1 assignee Claimed by @ivargrimstad View on GitHub
Dominant language
Java
Stars
55
Forks
25
Avg merge
3h 25m
Merged PRs (30d)
3

Description

I've got a [minimal MVC / Krazo application](https://github.com/user-attachments/files/26519200/mvc-playground.zip) set up with a form to enter some information. That information should be validated before being processed.

You can start the app with `mvn liberty:dev` - after that, go to http://localhost:9080/, click "Persons", click "Add". Enter a name and an age below 18. After hitting "Save", the user should see the form again, with some error information, but instead, the user sees a 400 response ("bad request"). In the OpenLiberty log, this message appears

```text
[WARNING ] save.person.age: must be greater than or equal to 18
```

This at least contradicts expectations :-) but more importantly it contradicts @ivargrimstad's answer to my question in #397.

My first impression is that probably, the "standard" bean validation mechanism in Jakarta RESTful Web Services kicks in "too early", preventing Krazo's [`ValidationInterceptor`](https://github.com/eclipse-ee4j/krazo/blob/main/jersey/src/main/java/org/eclipse/krazo/jersey/validation/KrazoValidationInterceptor.java) from being invoked. I had a few breakpoints in that class and they are hit when I do a "GET" retrieve the form (but obviously, all's good then), but they do not get hit when I do the "POST" with invalid data.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.