2 Replies Latest reply on Apr 10, 2014 5:42 AM by abl-dam

    Spezializes on a generic type does not deploy

    abl-dam Newbie

      we have generic beans in our system which we need to specialize in customer scenarios. Example:


      public class BeanDefault<T extends AbstractEntity>






      public class BeanCustom<T extends AbstractEntity> extends BeanDefault<T>




      as long as we have only BeanDefault in the classpath, deployment and injection points are working as expected. but if we add BeanCustom to the build we get the following error at startup:


      Caused by: org.jboss.weld.exceptions.DefinitionException: Exception message for key SPECIALIZING_BEAN_MISSING_SPECIALIZED_TYPE not found due to Can't find resource for bundle ch.qos.cal10n.util.CAL10NResourceBundle, key SPECIALIZING_BEAN_MISSING_SPECIALIZED_TYPE

      I guess the missing resource it is a subsequent error. The main error is that BeanCustom does not implement all Bean-Types of BeanDefault, but I don't understand why (it's clear from the Spec. that this is necessary for the container to accept the Specializes annotation).


      Even more confusing: if I remove the Specializes annotation and do something like:

      @Inject private BeanDefault<AbstractEntity> beanDefault;

      I get the ambiguous error at deployment (BeanDefault and BeanCustom). This is a kind of inconsistency for me.


      I searched through this forum, web and the spec. but found no hint if Specializes is even allowed on generic types. Maybe I overlooked something. Any help appreciated - many thanks!


      Environment: jboss-eap-6.0.1, weld-api-1.1.Final-redhat-2.jar, weld-core-1.1.10.Final-redhat-1.jar

        • 1. Re: Spezializes on a generic type does not deploy
          Tomas Remes Expert

          Hi Andreas.

          I think this is bug in Weld. I've tried with Weld 1.1.19.Final (EAP container) and Weld 2.2.0.CR2 (WildFly container) and in both cases i got following exception, which is IMHO inappropriate:


          org.jboss.weld.exceptions.DefinitionException: WELD-001511: Specializing bean Managed Bean [class mypackage.BeanCustom] with qualifiers [@Any @Default] does not have bean type class mypackage.BeanDefault<T> of specialized bean Managed Bean [class mypackage.BeanDefault] with qualifiers [@Any @Default]


          So far I've created [WELD-1651] Specialization of generic beans throws inappropriate exception - JBoss Issue Tracker and there's also need to file EAP tracking bug (will do later on).

          • 2. Re: Spezializes on a generic type does not deploy
            abl-dam Newbie

            Hi Tomas,

            thanks for your feedback and effort! I did some more tests, and i can workaround it by using an interface and the @Typed Annotation:



            public interface IBean<T extends AbstractEntity>

            and let the base class implement the interface reducing the Bean-Types to it with @Typed(IBean.class):


            public class BeanDefault<T extends AbstractEntity> implements IBean<T>


            for my case that is a possible solution, but I guess this is not intended and portable behaviour.

            instead using @Typed with the base class does NOT work (again the  WELD-001511 deployment error):

            // DEPLOYMENT ERROR


            public class BeanDefault<T extends AbstractEntity>