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

bean-discovery-mode="annotated" is not working like described in the spec

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • None
    • 10.1.0.Final
    • CDI / Weld
    • Hide

      See example code

      Show
      See example code

      I think we have a problem in Wildfly 10 concerning scanning of CDI Beans. Take a look at the following example:

      @Stateless
      @LocalBean
      public class SomeService {
       ...
      }
      
      
      public class SomeClass  {
      	@EJB
      	SomeService someService;
       ....
      }
      

      We have a stateless session ejb an a bean which is not annotated with a scope but is injecting the service EJB. If you use a beans.xml with the tag:

       bean-discovery-mode="annotated"
      

      this works in wildfly 10 - the someService is injected into the someClass which is treated as a CDI bean. But this is not a correct behavior as stated in the specification. It says, that in this case only beans with a scope annotation should be treated as CDI which is not the case for SomeClass. Normally, as a developer, you would not complain much about this. So this is only a minor issue.
      I recognized this after I tried to run my application on Glassfish/Payara4 which did no longer work until I changed the beans.xml tag to:

       bean-discovery-mode="all"
      

      Now it works in both application servers. I think in wildfly we are misinterpreting the attribute "bean-discovery-mode". I think this should be changed in the next versions for EE8. I don't know if this behavior is a known issue and maybe it is still under development.

      I know also that with such a change some projects (also my own ones) will break. So maybe a new configuration switch like "strict-cdi-scanning" is helpful. What do you think?

              mkouba@redhat.com Martin Kouba
              rsoika ralph Soika (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: