4 Replies Latest reply on Sep 18, 2015 1:31 AM by Sylvain Bonnemaison

    Arquillian Weld EE container bean discovery mode

    Sylvain Bonnemaison Newbie



      Using arquillian weld ee container with JUnit, the test result return the message "WELD-001409: Ambiguous dependencies" and list two beans. One of the bean is not tagged with CDI annotation. Does it means that the bean discovery mode is set to "all" by default ?

      The test is using a Web archive. The web archive include a Jar archive that embed these beans and a "beans.xml" resource. The beans.xml specify the <annotated> beans discovery mode. Changing the bean-discovery-mode flag in <beans-empty.xml> does not change discovered behavior. There is something wrong. Is it a problem with the weld container?



      public class CustomServiceConfiguration implements ServiceConfiguration {



      public class ServiceConfigurationFactory {
          public ServiceConfiguration configureService() {
             CustomServiceConfiguration config = new CustomServiceConfiguration();
              return config;



      public class ServiceConfigurationInjectionTest {
          public static Archive<?> deploy() {
              final String moduleName = ServiceConfigurationInjectionTest.class.getSimpleName();
              JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, moduleName + ".jar").addPackage(...)
                      .addAsManifestResource("beans-empty.xml", "beans.xml");
              JavaArchive[] libs = ArchiveUtils.getDeltaSpikeCoreArchive();
              WebArchive testWar = ShrinkWrap.create(WebArchive.class, moduleName + ".war").addAsLibraries(libs).addAsLibraries(testJar)
                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
              return testWar;
          ServiceConfiguration bean;

      With <beans.xml> resource into <testJar> the generated message is:

      org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type ServiceConfiguration with qualifiers @Default
        at injection point [BackedAnnotatedField] @Inject @CustomServiceConfig private ServiceConfigurationInjectionTest.bean
        at ServiceConfigurationInjectionTest.bean(ServiceConfigurationInjectionTest.java:0)
        Possible dependencies:
        - Managed Bean [class CustomServiceConfiguration] with qualifiers [@Any @Default],
        - Producer Method [ServiceConfiguration] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces @Singleton @CustomServiceConfig public ServiceConfigurationFactory.configureService()]

      Is there somthing wrong in the unit test ?


      Removing <beans.xml> resource from <testJar>, which means no bean discovered from <testJar> , generated this message:

      org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ServiceConfiguration with qualifiers @Default
        at injection point [BackedAnnotatedField] @Inject @CustomServiceConfig ServiceConfigurationInjectionTest.bean
        at ServiceConfigurationInjectionTest.bean(ServiceConfigurationInjectionTest.java:0)