1 Reply Latest reply on May 6, 2015 3:25 AM by tremes

    Issues with CDI when injecting generic type : Wildfly 8.2.0.Final

    srivathsan

      We are facing weird injection issues in Widfly due to CDI changes.  We have interface

      public interface Command<I, O> {

      }

      and many classes implement this interface  like this

      public class ApproveUserRequests implements Command<ApproveUserRequestsRequest, List<String>> {

      }

      Application listener classes likes to get list of all classes available and uses injection like this

       

        @Inject

          private Instance<Command<I, O>> mActions;

       

      However instance returned by mActions were always null. After debugging source found that the only way to get list of all instances is to use

       

        @Inject

          private Instance<Command<?, ?>> mActions;

       

      Also we faced injection issues while using generic types  , however using wildcard type helped us.