Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-13297

Weld @Resource injection does not handle expressions in the annotation attributes

    Details

      Description

      WFLY-1995 added support for expression resolution in the values of some attributes of some annotations, including @Resource. But this isn't applied to all handling of @Resource. ResourceInjectionAnnotationParsingProcessor handles some cases, which AFAICT means it's handled for EJBs (and perhaps other EE components) but it isn't handled in a simple CDI bean.

      You get a failure like this:

      Caused by: javax.naming.NameNotFoundException: ${the.expression} -- service jboss.naming.context.java."${the.expression}"
      	at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
      	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
      	at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:237)
      	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
      	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
      	at javax.naming.InitialContext.lookup(InitialContext.java:417)
      	at javax.naming.InitialContext.lookup(InitialContext.java:417)
      	at org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices.resolveResource(WeldResourceInjectionServices.java:236)
      	... 73 more
      

      The PropertyReplacer obtained from the DeploymentUnit that is used by ResourceInjectionAnnotationParsingProcessor is also available to the weld subsystem code that creates WeldResourceInjectionServices so a possible fix is to pass it in and have WeldResourceInjectionServices use it. Manual testing shows that allows an app with such a bean to work.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  brian.stansberry Brian Stansberry
                  Reporter:
                  brian.stansberry Brian Stansberry
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: