Uploaded image for project: 'WildFly WIP'
  1. WildFly WIP
  2. WFWIP-63

ConfigProperty injection for Provider<CustomClass> is not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • MP Config
    • None

      ConfigProperty injection for Provider<CustomClass> is not working

      Using https://github.com/rsvoboda/rsvoboda-playground/tree/master/microprofile-config-custom-converter-and-source application.

      This is working on OpenLiberty, but not on WF server. TBH I don't see reason why this shouldn't be working on WF too.

      First I thought it's problem in convertor not being picked up properly, but the problem seems to be triggered by https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-config-custom-converter-and-source/src/main/java/org/experiments/rsvoboda/system/SystemConfig.java#L18

      WF throws following error when accessing http://localhost:8080/microprofile-config/config/properties

      Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type Email with qualifiers @ConfigProperty
      	at org.jboss.weld.bean.builtin.InstanceImpl.checkBeanResolved(InstanceImpl.java:241)
      	at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:113)
      	at org.experiments.rsvoboda.system.SystemConfig.getEmail(SystemConfig.java:26)
      

      When I change the code to avoid javax.inject.Provider usage, things start to work as expected.

      --- src/main/java/org/experiments/rsvoboda/system/SystemConfig.java	(date 1531917469000)
      +++ src/main/java/org/experiments/rsvoboda/system/SystemConfig.java	(date 1531917469000)
      @@ -15,7 +15,7 @@
       
           @Inject
           @ConfigProperty(name = "io_openliberty_guides_email")
      -    private Provider<Email> email;
      +    private Email email;
       
       
           public boolean isInMaintenance() {
      @@ -23,7 +23,7 @@
           }
       
           public Email getEmail() {
      -        return email.get();
      +        return email;
           }
       
       }
      

      When trying the example please follow https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-config-custom-converter-and-source/README.md
      CustomConfigSource has to be adjusted.

              jmesnil1@redhat.com Jeff Mesnil
              rsvoboda@redhat.com Rostislav Svoboda
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: