Uploaded image for project: 'TEST Defect Tracking Project'
  1. TEST Defect Tracking Project
  2. TEST-1388

[quarkusio/quarkus] Can not inject restclients in validators anymore

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      Describe the bug

      Currently i migration a project from resteasy to rest. I do inject a @RestClient into a custom validator. Now using the new rest implementation, quarkus can not boot anymore:

      java.lang.RuntimeException: java.lang.ExceptionInInitializerError
      
      	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:667)
      	... 1 more
      Caused by: java.lang.RuntimeException: Failed to start quarkus
      	at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
      	... 8 more
      Caused by: java.lang.RuntimeException: Error injecting org.acme.rest.client.ExtensionsService org.acme.rest.client.CustomValidator.extensionsService
      	at org.acme.rest.client.ExtensionsService$$CDIWrapper_Bean.get(Unknown Source)
      	... 40 more
      

      Expected behavior

      I expected that i can also inject a restclient into a validator using the new rest implementation

      Actual behavior

      Quarkus does not come up

      How to Reproduce?

      vw.zip

      Create a custom validator that injects a restclient:

      @Documented
      @Constraint(validatedBy = Custom.Validator.class)
      @Target({ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER})
      @Retention(RetentionPolicy.RUNTIME)
      public @interface Custom {
      
          String message() default "";
      
          Class<?>[] groups() default {};
      
          Class<? extends Payload>[] payload() default {};
      
          class Validator implements ConstraintValidator<Custom, Extension> {
              @Inject
              @RestClient
              ExtensionsService extensionsService;
      
              @Override
              public boolean isValid(Extension value, ConstraintValidatorContext context) {
                  return false;
              }
          }
      }
      

      Annotate a entity with it:

      @Custom
      public class Extension {

      Try to start

      Output of uname -a or ver

      Linux cody-MS-7E12 6.11.0-26-generic #26~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 17 19:20:47 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

      Output of java -version

      openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment (build 21.0.2+13-58) OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

      Quarkus version or git rev

      3.23.2

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

      Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /home/cody/.m2/wrapper/dists/apache-maven-3.9.9-bin/33b4b2b4/apache-maven-3.9.9 Java version: 21.0.2, vendor: Oracle Corporation, runtime: /home/cody/Downloads/openjdk-21.0.2_linux-x64_bin/jdk-21.0.2 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.11.0-26-generic", arch: "amd64", family: "unix"

      Additional information

      No response

              Unassigned Unassigned
              wscales@redhat.com Webb Scales
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: