0 Replies Latest reply on Apr 3, 2012 9:33 AM by Arto Huusko

    AS 7.1.1: EJB 3 deployment failure with <injection-target>

    Arto Huusko Newbie

      My EJB 3 session deployment fails on AS 7.1.1 with error:

       

      org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011068: Injection target session2 on class Session1Bean is not compatible with the type of injection: interface Session2Local

       

      In short:

      • There are two stateless sessions: Session1 and Session2
      • Session2 has both a local and remote interface, Session2Local and Session2Remote. These interfaces extend a common superinterface, Session2.
      • Session1Bean has field session2 whose type is Session2 (that is the superinterface)
      • In ejb-jar.xml, Session1 depends on Session2 using <ejb-local-ref>, which has <injection-target> for Session1Bean.session2
      • Fail

       

      As far as I can see, this is a bug in JBoss. In org.jboss.as.ee.component.deployers.AbstractDeploymentDescriptorBindingsProcessor.processInjectionTargets there is this check:

       

           if (!classType.isAssignableFrom(injectionTargetType))

       

      classType seems to be what is defined in the <local> element in <ejb-local-ref> (Session2Local). injectionTargetType is the type of the field (Session2).

      Thus the check checks: is Session2Local assignable from Session2. The check is of course wrong: it should be the reverse:

       

           if (!injectionTargetType.isAssignableFrom(classType)))

       

      that is: is Session2 assignable from Session2Local.

       

      Attached broken JAR with source.