4 Replies Latest reply on Dec 2, 2009 6:49 AM by Alexander Bell

    Alternative Sterotype with Producer Method

    Alexander Bell Newbie

      Hi,


      I've got a Alternative Stereotype Test:



      @Stereotype
      @Alternative
      @Retention(RetentionPolicy.RUNTIME)
      @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
      public @interface Test {}





      That Alternative is used by the following producer method:



      @Produces @Test @PersistenceManager
      public PersistenceManager getTestManager() {...}





      In the same class there's another producer method without the Alternative



      @Produces @PersistenceManager
      public PersistenceManager getManager() {...}





      My beans.xml



      <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
           <alternatives>
                <stereotype>org.j4fry.type.Test</stereotype>
           </alternatives>
      </beans>



      Unfortunately on Startup I get the following exception



      org.jboss.weld.DeploymentException: Injection point has ambiguous dependencies. 
      Injection point: field org.j4fry.service.impl.SecuritiesServiceImpl.persistenceManager; 
      Qualifiers: [@org.j4fry.type.PersistenceManager()]; 
      Possible dependencies: 
           [org.jboss.weld.bean-flat-ProducerMethod-org.j4fry.util.PersistenceUtil.getManager(), 
           org.jboss.weld.bean-flat-ProducerMethod-org.j4fry.util.PersistenceUtil.getTestManager()]




      Any ideas?


      Alex