6 Replies Latest reply on Nov 4, 2010 1:10 AM by Marius Bogoevici

    Ambiguous dependencies class repeated twice

    damian pooley Newbie

      I 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.

        • 1. Re: Ambiguous dependencies class repeated twice
          Stuart Douglas Master
          M5 has known problems in this area, this snapshot may fix the problem:

          http://people.redhat.com/~pmuir/jboss-as-distribution-6.0.0-SNAPSHOT.zip
          • 2. Re: Ambiguous dependencies class repeated twice
            damian pooley Newbie

            Thanks, I'll download and give it a go.

            • 3. Re: Ambiguous dependencies class repeated twice
              Heiko Tappe Newbie

              I tried the weld translator example with JBoss 6 M5 and the snapshot mentioned above.
              I ran into different errors:


              M5: WELD-001414 Bean name is ambiguous
              SNAPSHOT: Unable to lookup BeanManager.


              Any suggestions?


              --Heiko


              M5: stacktrace


              2010-10-29 08:14:20,422 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (Thread-2) Error installing to Start: name=vfs:///C:/Programme/jboss-6/server/transdata/deploy/weld-translator.ear_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name translator resolves to beans [Session bean [class org.jboss.weld.examples.translator.TranslatorControllerBean with qualifiers [@Any @Default @Named]; local interfaces are [TranslatorController], Session bean [class org.jboss.weld.examples.translator.TranslatorControllerBean with qualifiers [@Any @Default @Named]; local interfaces are [TranslatorController]]
                   at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:461)
                   at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:357)
                   at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:436)
                   at org.jboss.weld.integration.deployer.env.helpers.BootstrapBean.boot(BootstrapBean.java:118) [:6.0.0.20100911-M5]
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]
                   at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]
                   at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:60) [jboss-reflect.jar:2.2.0.Alpha9]
                   at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:168) [jboss-reflect.jar:2.2.0.Alpha9]
                   at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) [jboss-reflect.jar:2.2.0.Alpha9]
                   at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:257) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:202) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.Alpha7]
                   at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.Alpha7]
                   at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.Alpha7]
                   at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.20100911-M5]
                   at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:130) [:0.1.0.Alpha1]
                   at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:148) [:0.1.0.Alpha1]
                   at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.1.0.Alpha1]
                   at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.Alpha10]
                   at org.jboss.profileservice.dependency.ProfileServiceController.activate(ProfileServiceController.java:188) [:0.1.0.Alpha1]
                   at org.jboss.profileservice.AbstractProfileService.activateProfile(AbstractProfileService.java:170) [:0.1.0.Alpha1]
                   at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:117) [:0.1.0.Alpha1]
                   at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:89) [:0.1.0.Alpha1]
                   at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:97) [:0.1.0.Alpha1]
                   at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:130) [:6.0.0.20100911-M5]
                   at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.0.20100911-M5]
                   at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
                   at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
                   at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]
              



              SNAPSHOT stacktrace:



              Caused by: java.lang.RuntimeException: Unable to lookup BeanManager.
                      at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:126) [:]
                      at org.jboss.resteasy.cdi.CdiInjectorFactory.<init>(CdiInjectorFactory.java:42) [:]
                      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.6.0_21]
                      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [:1.6.0_21]
                      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [:1.6.0_21]
                      at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [:1.6.0_21]
                      at java.lang.Class.newInstance0(Class.java:355) [:1.6.0_21]
                      at java.lang.Class.newInstance(Class.java:308) [:1.6.0_21]
                      at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:154) [:]
                      ... 65 more



              • 4. Re: Ambiguous dependencies class repeated twice
                Heiko Tappe Newbie

                Ahhhh... works with latest jboss 6 snapshot! :-)


                --Heiko

                • 5. Re: Ambiguous dependencies class repeated twice
                  Heiko Tappe Newbie

                  But only the deployment seems to work. Not the application itself :-(
                  When I try to translate something I get the following error:



                  WARNUNG [javax.enterprise.resource.webcontainer.jsf.lifecycle] /home.xhtml @24,110 value="#{translator.text}": Target Unreachable, identifier 'translator' resolved to null: javax.el.PropertyNotFoundException: /home.xhtml @24,110 value="#{translator.text}": Target Unreachable, identifier 'translator' resolved to null
                          at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:97) [:2.0.3-SNAPSHOT]
                          at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:91) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1023) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIInput.validate(UIInput.java:953) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIInput.executeValidate(UIInput.java:1204) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIInput.processValidators(UIInput.java:693) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIForm.processValidators(UIForm.java:240) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081) [:2.0.3-SNAPSHOT]
                          at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1159) [:2.0.3-SNAPSHOT]
                          at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:72) [:2.0.3-SNAPSHOT]
                          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-SNAPSHOT]
                          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-SNAPSHOT]
                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-SNAPSHOT]
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:]
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
                          at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:63) [:]
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:]
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
                          at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68) [:6.0.0-SNAPSHOT]
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:]
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]
                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:]
                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:]
                          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0-SNAPSHOT]
                          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
                          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
                          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0-SNAPSHOT]
                          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0-SNAPSHOT]
                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:]
                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:]
                          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0-SNAPSHOT]
                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:]
                          at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0-SNAPSHOT]
                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:]
                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:]
                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:]
                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:]



                  • 6. Re: Ambiguous dependencies class repeated twice
                    Marius Bogoevici Newbie

                    Heiko,


                    please try the latest trunk. I just closed https://jira.jboss.org/browse/JBAS-8590 which deals with this issue.


                    Thanks,
                    Marius