Q:

CDI error: Ambiguous dependencies trying to inject EntityManager

I'm facing a strange error while trying to deploy my EJB 3.1 application in a JBoss 7.1.1 application server: WELD-001409 Ambiguous dependencies for type [EntityManager] with qualifiers [@Default] at injection point [[parameter 1] of [constructor] @Inject public br.com.sigga.siot.dao.masterdata.impl.ProfileDAOImpl(EntityManager)]. Possible dependencies [[Resource Producer Field [EntityManager] with qualifiers [@Any @Default] declared as [[field] @PersistenceContext @Produces private br.com.sigga.siot.cdi.JPAProducer.entityManager], Resource Producer Field [EntityManager] with qualifiers [@Any @Default] declared as [[field] @PersistenceContext @Produces private br.com.sigga.siot.cdi.JPAProducer.entityManager]]]
As you can see, the "possible dependencies" points twice to the same EntityManager producer: br.com.sigga.siot.cdi.JPAProducer.entityManager. This field is declared as follows:
@PersistenceContext(unitName = "siotMobility")
@Produces
private EntityManager entityManager;

A similar case was related in WELD-001409 Ambiguous dependencies but I cannot change my application server to Glassfish 4.1. :-)
My development environment: Eclipse Luna, Java 7, Maven 3.x (eclipse's embedded version). I have one Maven project (siot-mobility) with 3 modules (siot-mobility-[ear|ejb|web]).
The EAR module's POM declares the following dependencies:
<dependencies>
    <dependency>
        <groupId>br.com.sigga</groupId>
        <artifactId>siot-mobility-web</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>br.com.sigga</groupId>
        <artifactId>siot-mobility-ejb</artifactId>
        <version>${project.version}</version>
        <type>ejb</type>
    </dependency>
</dependencies>

Maven EAR plugin configuration:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
        <version>6</version>
        <defaultLibBundleDir>lib</defaultLibBundleDir>
        <modules>
            <webModule>
                <groupId>br.com.sigga</groupId>
                <artifactId>siot-mobility-web</artifactId>
            </webModule>
            <ejbModule>
                <groupId>br.com.sigga</groupId>
                <artifactId>siot-mobility-ejb</artifactId>
            </ejbModule>
        </modules>
    </configuration>
</plugin>

Feel free to ask me about any more info that could help you help me. :-) Thanks in advance.

A:

Error found: the EJB module was present twice in the generated EAR, once on the root path of the EAR file and a second time in the WEB-INF/lib folder of the WAR file. 
I changed the dependency declaration in the WAR project's POM file from:
<dependency>
    <groupId>br.com.sigga</groupId>
    <artifactId>siot-mobility-ejb</artifactId>
</dependency>

to:
<dependency>
    <groupId>br.com.sigga</groupId>
    <artifactId>siot-mobility-ejb</artifactId>
    <scope>provided</scope>
</dependency>

This way, the EJB module is not copied to the WEB-INF/lib folder of the WAR file and I have only one EntityManager producer in the generated EAR file.

