3 Replies Latest reply on Jul 28, 2010 6:41 AM by risrod

    injecting a local EJB into a service POJO

    mhsheikh

      I'm migrating from JBoss AS 4.2.x to JBoss AS 5.1. I noticed that my "service pojos" stopped working when I deploy my app in JBoss AS 5.1 (i.e., the start and create methods are not called automatically).

       

      I changed the @service annotation from  org.jboss.annotation.ejb.Service; to org.jboss.ejb3.annotation.Service and it seems that the service is being recognized now. However, I got into another problem: My Service POJO has a reference to a local EJB. In Jboss 4, I could easily annotate the field with @EJB and the deoendency was recognied and the EJB was injected. However, in JBoss 5.1, the deployed gives me an error message of type

      "DEPLOYMENTS MISSING DEPENDENCIES"

       

      I tried using the @Depends annotation as follows

      @Depends("jboss.j2ee:ear=xxxx,jar=yyy.jar,name=zzz,service=EJB3")

       

      But it didn;t help. I'd appreciate it if anyone can tell me how an EJB could be injected into a JBoss Service POJO.

       

      Thanks

        • 1. Re: injecting a local EJB into a service POJO
          jaikiran

          mhsheikh wrote:

           

           

           

          I changed the @service annotation from  org.jboss.annotation.ejb.Service; to org.jboss.ejb3.annotation.Service


          All org.jboss.annotation.ejb.* annotations have been moved to org.jboss.ejb3.annotation.* in AS-5

           

          mhsheikh wrote:

           


           

          I tried using the @Depends annotation as follows

          @Depends("jboss.j2ee:ear=xxxx,jar=yyy.jar,name=zzz,service=EJB3")

           

          But it didn;t help.


           

          Did you use org.jboss.ejb3.annotation.Depends? And is that the right ObjectName for the depends (you can check the jmx-console)?

          1 of 1 people found this helpful
          • 2. Re: injecting a local EJB into a service POJO
            mhsheikh

            UPDATE:

            The @EJB annotation does work in JBoss 5.1

            The reason that it didn't work in my case was a mistake on my part.

            • 3. Re: injecting a local EJB into a service POJO
              risrod

              I post the solution that helped me (hope will help other people):

               

              I moved the code that use the injected ejb from the create() lifecycle method to the start() lifecycle method, by this way the ejb is correct injected. Same concept for the destory()  and the stop() method.