Search code examples
quarkusquarkus-native

Using two different ValidationFactory classes


I would like to produce two different ValidatorFactory classes in my quarkus application. This works fine in jvm mode, but in native mode, the validation fails with Bean not found exceptions.

I know the hibernate validator is heavily wrapped by quarkus, but is it possible to use two (or more) ValidationFactory classes in quarkus native build or can there be only one?

Update: our usecase was to workaround https://github.com/quarkusio/quarkus/issues/35007#issuecomment-1655908939 It is not possible for the moment, we wait for the update.

Update 2: 2.16.9 solved the issues for us.


Solution

  • Creating your own ValidatorFactory is not supported in Quarkus, mostly due to native, but also because it allowed us to configure things very carefully and optimize things.

    In JVM, as you noted, it will somehow work as you can create a ValidatorFactory in JVM, but in native, it won't work at all due to how native binaries are built and because of the restrictions on reflection usage.

    Could you tell me more about your use case? And how you envisioned it to work? I suppose you wanted two different configurations for the two ValidatorFactory?

    Now, I don't recall exactly all the restrictions I hit when I initially developed the Hibernate Validator support in Quarkus and GraalVM has made enormous progress since the beginning of Quarkus.

    Maybe create an issue in the Quarkus tracker with a small Maven reproducer showing what you're trying to do and I'll try to have a look in the next few days.