Skip to content

[Rest-Client] ConstraintDeclarationException HV000151 When using Validation Constraints on Container Elements #48898

@PhilippParis

Description

@PhilippParis

Describe the bug

When using bean validation annotation on container elements e.g. List<@Valid User> body in a method of a RestClient interface under certain circumstances startup fails with:

Caused by: jakarta.validation.ConstraintDeclarationException: HV000151: A method overriding another method must not redefine the parameter constraint configuration, but method ExampleRestClient$$CDIWrapper#post8(String, List) redefines the configuration of ExampleRestClient#post8(String, List).

Reproducer:
add the following class to a quarkus project which uses quarkus-rest-client (and uncomment the example methods).
run quarkus -> startup fails
(issue is not present in quarkus-resteasy-client)

@Path("/example")
@RegisterRestClient
public interface ExampleRestClient {
	// OK
	@POST void post1(@QueryParam("a") @Size(min = 4, max = 32) String query);

	@POST void post2(@QueryParam("a") @Size(min = 4, max = 32) String query, @Valid User body);

	@POST void post3(List<@Size(min=4, max=64) String> body);

	@POST void post4(@Valid List<@Size(min=4, max=64) String> body);

	@POST void post5(@Valid User body);

	@POST void post6(List<@Valid User> body);

	@POST void post7(@QueryParam("a") String query, List<@Valid User> body);

	// NOT OK

	// @POST void post8(@NotNull List<@Valid User> body);

	// @POST void post9(@QueryParam("a") @Size(min = 4, max = 32) String query, List<@Valid User> body);

	// @POST void post10(@Valid List<@Valid User> body);
}

Expected behavior

Quarkus starts, restclient works with bean validation

Actual behavior

ERROR [io.qua.run.Quarkus] Error running Quarkus: java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.misc.Unsafe.allocateInstance(Native Method)
        at java.base/java.lang.invoke.DirectMethodHandle.allocateInstance(DirectMethodHandle.java:501)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:79)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:51)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:144)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:121)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
        ... 10 more
Caused by: jakarta.enterprise.inject.CreationException: Error creating synthetic bean [cjc3qHBmUB1ZLkEsO6nVgOk3474]: jakarta.validation.ConstraintDeclarationException: HV000151: A method overriding another method must not redefine the parameter constraint configuration, but method ExampleRestClient$$CDIWrapper#post9(List) redefines the configuration of ExampleRestClient#post9(List).

How to Reproduce?

No response

Output of uname -a or ver

Linux - 6.8.0-60-generic #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

21.0.7+6-Ubuntu-0ubuntu124.04, mixed mode, sharing)openjdk version "21.0.7" 2025-04-15 OpenJDK Runtime Environment (build 21.0.7+6-Ubuntu-0ubuntu124.04) OpenJDK 64-Bit Server VM (build

Quarkus version or git rev

3.24.3

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

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions