3 Replies Latest reply on Mar 19, 2013 4:32 AM by sven.plath

    Ambiguous dependencies when two beans.xml are in one WAR - CDI Injection

    sven.plath

      Hello,

       

      I noticed the following behavior. Consider two classes, Bean and InjectionPoint as follows:

       

      @Stateless
      @LocalBean
      public class Bean {
        
      }
      

       

      @Singleton
      @Startup
      public class InjectionPoint {
                @Inject
                private Bean bean;
      }
      

       

      When having only one beans.xml (for example in src\main\webapp\WEB-INF), everything deploys fine. However when accidentially added another (for example src\main\resources\META-INF), the deployment fails with the message:

       

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [Bean] with qualifiers [@Default] at injection point [[field] @Inject private com.durr.lab.bugs.InjectionPoint.bean]......

       

      I know that it is no 'real' problem because no one should have more than one beans.xml. But I also assume that this behavior is not intended. When this is related to WELD and not to JBoss AS, please move the thread.

       

      Some more information:

      1) org.jboss.weld.deployer log output

      08:40:57,036 DEBUG [org.jboss.weld.deployer] (MSC service thread 1-3) Found beans.xml: "/D:/Dev/Programs/Servers/jboss-as-7.2.0.Final/bin/content/bugs.war/WEB-INF/beans.xml"

      08:40:57,083 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016002: Processing weld deployment bugs.war

      08:40:57,084 DEBUG [org.jboss.weld.deployer] (MSC service thread 1-2) Found external beans.xml: vfs:/D:/Dev/Programs/Servers/jboss-as-7.2.0.Final/bin/content/bugs.war/WEB-INF/classes/META-INF/beans.xml

       

      2) org.jboss.weld.Bootstrap log output

      08:40:57,173 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-2) WELD-000106 Bean: Managed Bean [class com.durr.lab.bugs.Bean] with qualifiers [@Any @Default]

      08:40:57,195 DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-2) WELD-000106 Bean: Session bean [class com.durr.lab.bugs.Bean with qualifiers [@Any @Default]; local interfaces are [Bean]

       

      Notice the Session Bean and Managed Bean!

       

      Thanks.

       

      Regards,

      Sven