Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WELD-001318 Cannot resolve an ambiguous dependency

I am getting an error when deploying my application as follows..

Caused by: org.jboss.weld.exceptions.AmbiguousResolutionException: WELD-001318 Cannot resolve an ambiguous dependency between [
Producer Method [String] with qualifiers [@Any @Config] declared as [[method] @Produces @Config public ca.comdev.cdip.mis.enterpriseportal.configuration.ConfigurationProvider.getConfigurationValue(InjectionPoint)], 

Producer Method [String] with qualifiers [@Any @Config] declared as [[method] @Produces @Config public ca.comdev.cdip.mis.enterpriseportal.configuration.ConfigurationProvider.getConfigurationValue(InjectionPoint)]]

And I only have on such method whose header looks like this

@Produces @Config public String getConfigurationValue(InjectionPoint p) throws ConfigurationException{...}

and class has these

@Named
@Singleton
@Startup
public class ConfigurationProvider {...}

Please help. This error is probably more ambiguous than my code.

like image 312
Peter Vanleeuwen Avatar asked Aug 29 '11 20:08

Peter Vanleeuwen


1 Answers

This error occurred to me by accidentally using the same EJB name "ExternalClient" in 2 different modules.

 <enterprise-beans>
    <session>
        <ejb-name>ExternalClient</ejb-name> <!-- DUPLICATED -->
        <ejb-class>com.company.ExternalClient</ejb-class>
        <session-type>Stateless</session-type>
        <env-entry>
            <env-entry-name>url</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>http://company.com/API</env-entry-value>
        </env-entry>
    </session>
</enterprise-beans>

This could be detected when using JBoss by checking the JNDI bindings during deployment. The EJB was instantiated more than once.

like image 196
Pool Avatar answered Sep 21 '22 12:09

Pool