1 Reply Latest reply on Apr 14, 2011 7:21 AM by jaikiran

    @EJB and Class Hierarchy

    mclu

      Hi!

       

      Currently I am migrating an application from AS 4.2.3 to AS 6.0.0

       

      In the old system we have a hierarchy like:

       

      @Stateless(name = "CarrierUC")

      public class CarrierUCBean extends AbstractUC implements CarrierUC {

      ....

      }

       

      and a subclass like

       

      @Stateless(name = "PersonUC")

      public class PersonUCBean extends CarrierUCBean implements PersonUC {

      ....

      }

       

      Other Session Beans inject them using

       

      @EJB CarrierUC m_carrierUC;

      or

      @EJB PersonUC m_personUC;

       

       

      Now with Jboss 6 the system could not deploy my beans because he mention that the injected CarrierUC is not unique and I should use beanName.

      Message:

      Caused by: java.lang.RuntimeException: Specified reference [EJB Reference: beanInterface 'com.XXX.CarrierUC', beanName 'null', mappedName 'null', lookupName 'null', owning unit 'ComponentDeploymentContext@17671586{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.MyClientService}'] was matched by more than one EJB: [org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@1e4488c3{PersonUC}, org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@81412b66{CarrierUC}, org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@12e9e9a{VehicleUC}].  Specify beanName explicitly or ensure beanInterface is unique.


      OK, when I use

      @EJB(beanName="CarrierUC") CarrierUC m_carrierUC;

      it works.

       

      Do I really have to change ALL my injection lines where I have session bean class hierarchies or is there a way to configure the old behavior?

       

      Thx from Germany

      Markus

       

       



        • 1. @EJB and Class Hierarchy
          jaikiran

          The old behaviour in 4.2.x wasn't spec compliant. The new behaviour is. So yes, you'll have to explicitly let the container know which bean you are interested in, if there are multiple beans of the same class type.