Ambiguous dependencies class repeated twice
surfingspider Oct 21, 2010 1:43 AMI have just upgraded from JBoss6M3 to M5 and tried deploying my poc application and ran into the following error:
org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [EJBDomain] with qualifiers [@Domain] at injection point [[field] @Domain @Inject cdi.domain.webservice.WebServiceInbound.domain]. Possible dependencies [[ Session bean [class cdi.domain.service.EJBDomainBean with qualifiers [@Any @Domain]; local interfaces are [EJBDomain], Session bean [class cdi.domain.service.EJBDomainBean with qualifiers [@Any @Domain]; local interfaces are [EJBDomain ]]]
The cdi.domain.service.EJBDomainBean is listed twice for some reason.
I have a webservice injecting the bean:
Stateless @WebService(endpointInterface = "cdi.domain.webservice.IWebService") public class WebServiceInbound implements IWebService { @Inject @Domain EJBDomain domain; @WebMethod(operationName = "saveMe") public Object saveMe(@WebParam(name = "payload")Object o) {...
The Bean interface:
public interface EJBDomain { //Entity getEntity(); void store(Entity entity) throws Exception; }
The Bean impl:
@Domain @Stateless public class EJBDomainBean implements EJBDomain { @Resource(mappedName="java:RemoteJmsXA") private ConnectionFactory connectionFactory; public void store(Entity entity) throws Exception { // create a jms message to send to the ESB for persistence to the IMDG onto the queue gsstore Connection connection = connectionFactory.createConnection("guest", "guest"); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = HornetQJMSClient.createQueue("gsstore"); MessageProducer producer = session.createProducer(destination); ObjectMessage message = session.createObjectMessage(); message.setObject(entity); producer.send(message); connection.close(); System.out.println("4"); } }
There is also an ActionBean (UI) that injects the @domain
@Named("action") @ConversationScoped public class ActionBean implements Serializable { private static final long serialVersionUID = 1L; @Inject @Domain EJBDomain ejbDomain; @Inject Conversation conversation; Entity entity; @PostConstruct void init() { this.entity = null;//ejbDomain.getEntity(); } public String start() { conversation.begin(); return "operation11?faces-redirect=true"; } public String save() { conversation.end(); try { ejbDomain.store(entity); } catch (Exception e) { e.printStackTrace(); } return "home?faces-redirect=true"; } public Entity getEntity() { return this.entity; } }
I will repeat that in JBoss6M3 all the above worked fine. M5 was a fresh install. I use Eclipse to run and deploy with JBoss as a server. Confirmed that the class is only in the ear once in the ejb.jar. Replacing @Domain with @Default results in same error.