3 Replies Latest reply on Sep 20, 2006 10:07 PM by bill.burke

    @EJB Injection Not Working

    alrubinger

      After upgrading today my JBoss 4.0.4-GA installation to EJB3 RC9, I've found that the @EJB injections in my code are not populating my instance variables as they had been previous to the upgrade.

      I have created a project with sources, build script, and deployable example of the use case. Will be happy to upload/email this if instructed.

      I'd like to volunteer to fix if confirmed that this is a bug and can be shown proper branches in JBoss source to correct.

      S,
      ALR

      Partial Code Listing from Use Case Project

      package com.alrubinger.jboss.usecase.ejbinjectionfailure;
      
      import javax.annotation.EJB;
      
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      import org.jboss.annotation.ejb.Depends;
      import org.jboss.annotation.ejb.LocalBinding;
      import org.jboss.annotation.ejb.RemoteBinding;
      import org.jboss.annotation.ejb.Service;
      
      @Service(objectName = "alrubinger:service=ServiceA")
      @Depends( { "alrubinger:service=ServiceB" })
      @LocalBinding(jndiBinding = "alrubinger/service/serviceA/local")
      @RemoteBinding(jndiBinding = "alrubinger/service/serviceA/remote")
      public class ServiceABean implements ServiceA, ServiceAManagement {
      
       // Class Members
       private static final Log logger = LogFactory.getLog(ServiceABean.class);
      
       // Instance Members
       @EJB
       private ServiceB injectedReference;
      
       // Required Implementations
      
       /**
       * Test Method
       */
       public String test() {
       return "SUCCESSFUL TEST SERVICE A";
       }
      
       // Lifecycle Methods
       /*
       * (non-Javadoc)
       *
       * @see com.alrubinger.jboss.usecase.ejbinjectionfailure.EjbAManagement#start()
       */
       public void start() throws Exception {
       logger.info("In start...");
       logger.info("Calling injected reference...");
       // >>> NULLPOINTER DUE TO NO INJECTION <<<
       logger.info(injectedReference.test());
       // THIS LINE NOT REACHED
       logger.info("Start Done; OK.");
       }
      }