Quando crio o arquivo EntityManagerProducer:
public class EntityManagerProducer {
@Produces
@RequestScoped
public EntityManager createEntityManager() {
return JPAUtil.criaEntityManager();
}
}
que retorna o JPAUtil:
public class JPAUtil {
public static EntityManager criaEntityManager() {
EntityManagerFactory factory = Persistence
.createEntityManagerFactory("default");
return factory.createEntityManager();
}
}
ele gera o seguinte erro:
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type EntityManager with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public br.com.caelum.vraptor.dao.ProdutoDao(EntityManager)
at br.com.caelum.vraptor.dao.ProdutoDao.<init>(ProdutoDao.java:0)
Possible dependencies:
- Producer Method [EntityManager] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces @RequestScoped public br.com.caelum.vraptor.producers.EntityManagerProducer.createEntityManager()],
- Producer Method [EntityManager] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces @RequestScoped public br.com.caelum.vraptor.jpa.EntityManagerCreator.getEntityManager()]