6 Replies Latest reply on Aug 24, 2018 4:56 AM by Hegyi Gergely

    WELD-000132: Disabled alternative

    Hegyi Gergely Newbie

      I have an implementation class, and a Mock class for that implementation. Both class implement an interface.

       

      Server: wildfly-8.2.0.Final (with 9.0 same result)

       

      Interface:

      public interface Validator {

       

           dosomething...

      }

       

      Primary implementation:

      @Stateless
      public class ValidatorBean implements Validator {

           dosomething...

      }

       

      Mock:

      @Alternative

      public class MockValidatorBean implements Validator {

           dosomething...

      }

       

      And when I try to use a mock (create a row in beans.xml):

       

      <alternatives>

        <class>com.package.MockValidatorBean</class>

        </alternatives>

       

      It doesn't work. I tried to debug, but there are no information. I see some debug log, for recognised alternatives from beans.xml. But the primary class has been injected.

       

      I try to use stereotype:

      @Stereotype
      @Alternative
      @Target( { TYPE, METHOD, FIELD })

      @Retention(RUNTIME)

      public @interface NoValidation {

      }

       

      Changed mock class:

      @NoJWTValidation

      public class MockValidatorBean implements Validator {

           dosomething...

      }

       

      beans.xml:

      <alternatives>
        <stereotype>com.package.NoValidation</stereotype>
      </alternatives>

       

      And I got one relevant line:

      DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-8) WELD-000132: Disabled alternative (ignored): Managed Bean [class com.package.MockValidatorBean] with qualifiers [@Any @Default]

       

      When i put the @Prioroty(300) into the Mock class, it works.

       

      How can I fix this issue?