5 Replies Latest reply on Aug 31, 2011 4:38 AM by gunterze

    @EJB injection not working in JBoss 6.x

    gunterze

      I tried to use @EJB annotation in MC bean in JBoss AS 6.x to inject SLSB, but without success. There is no error log, the annotated field just remains null. Doing the JNDI lookup manually works. Have I activate the EjbReferenceAnnotationPlugin in some way?

       

      Thanks,

      gunter

        • 1. Re: @EJB injection not working in JBoss 6.x
          beve

          Hi Gunter,

           

          I'm not sure if this is your issue, but when I forget to add a META-INF/beans.xml I get the same behaviour. No error and the injected resource in null as I believe WELD will not pick up the deployment and hence not scanning it for annotations. 

           

          Regards,

           

          /Daniel

          • 2. Re: @EJB injection not working in JBoss 6.x
            alesj

            I'm not sure if this is your issue, but when I forget to add a META-INF/beans.xml I get the same behaviour. No error and the injected resource in null as I believe WELD will not pick up the deployment and hence not scanning it for annotations. 

            I think this is a diff issue; Weld != MC. ;-)

            • 3. Re: @EJB injection not working in JBoss 6.x
              alesj

              I tried to use @EJB annotation in MC bean in JBoss AS 6.x to inject SLSB, but without success. There is no error log, the annotated field just remains null. Doing the JNDI lookup manually works. Have I activate the EjbReferenceAnnotationPlugin in some way?

              Did you follow ALR's instructions on how to do this?

              * http://exitcondition.alrubinger.com/2008/12/20/doing-two-models-at-the-same-time/

              1 of 1 people found this helpful
              • 4. Re: @EJB injection not working in JBoss 6.x
                gunterze

                I thought ALR's solution with

                 

                org.jboss.ejb3.mcint.metadata.plugins.EjbReferenceAnnotationPlugin

                org.jboss.ejb3.mcint.metadata.plugins.AbstractEjbReferenceValueMetadata

                org.jboss.ejb3.mcint.annotationadaptor.AddAnnotationPluginOnBeanAnnotationAdaptorCallbackService

                 

                is already included in JBoss 6.x and deployed by jboss-6.1.0.Final/server/default/deployers/ejb3.deployer/META-INF/ejb3-deployers-jboss-beans.xml:

                 

                  <!-- Add Annotation Plugins upon installation -->

                  <bean name="org.jboss.ejb3.AddAnnotationPluginOnBeanAnnotationAdaptorCallbackService" 

                    class="org.jboss.ejb3.mcint.annotationadaptor.AddAnnotationPluginOnBeanAnnotationAdaptorCallbackService">

                    <constructor>

                      <parameter><inject bean="jboss.kernel:service=Kernel"/></parameter>

                    </constructor>

                  </bean>

                  

                  <!-- TODO: Move this out of core -->  

                  <!-- EJB Reference Annotation Plugin -->

                  <bean name="org.jboss.ejb3.EjbReferenceAnnotationPlugin"

                    class="org.jboss.ejb3.mcint.metadata.plugins.EjbReferenceAnnotationPlugin">

                    <constructor>

                      <parameter><inject bean="org.jboss.ejb3.EjbReferenceResolver" /></parameter>

                    </constructor>

                  </bean>

                 

                by default. Isn't it?

                • 5. Re: @EJB injection not working in JBoss 6.x
                  gunterze

                  Oops, I missed your comment at http://exitcondition.alrubinger.com/2008/12/20/doing-two-models-at-the-same-time/ :

                   

                  Perhaps a missing detail that gave you problems as well is the no-fields by default.

                  Meaning one must change BeanAccessMode –> FIELDS or ALL.

                   

                  Adding

                  <bean .. access-mode="ALL">

                  and it works as expected. Thanks!