Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1108

Bean with a @Named stereotype is not injected into a @Named injection point

XMLWordPrintable

      1. Create a stereotype @MyStereotype annotated @Named.
      2. Create a bean class test.MyBean annotated @MyStereotype. Now, there is EL name 'myBean' available.
      3. Create, in another class bean, an injection point @Inject @Named MyBean myBean.
      4. Deploy the application
      Error: WELD-001408 Unsatisfied dependencies for type [MyBean] with qualifiers [@Named] at injection point [[field] @Named @Inject test.AnotherBean.myBean]
      5. Add @Named to test.MyBean and deploy the application again.
      Success.

      I am not sure if it is a bug. Section 5.2. "Typesafe resolution" says that in order to be injected, the bean should have all the required qualifiers, and @Named is a required qualifier at the injection point 'myBean'. The question is, can we consider that a bean has qualifier @Named if it is annotated by a @Named stereotype? I could not find a plain statement in JSR-299 on that. However, if a stereotype A declares another stereotype B, a bean annotated with A is as good as one annotated with both A and B (section 2.7.5.1. says 'stereotype declarations are transitive'); and annotation @Named added to a stereotype A gives EL name to a bean annotated with A, as if it is annotated with @Named explicitly. Is it enough to answer 'yes' to the question above, or is it a 'jumping to conclusions' case?

            marko.luksa@gmail.com Marko Luksa (Inactive)
            scabanovich Viacheslav Kabanovich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: