5 Replies Latest reply on Jan 4, 2009 5:20 AM by Nicole Schweighardt

    How to inject sessionbean from sessionbean

    Nicole Schweighardt Novice

      Hi,

      for injecting my sessionBean "groupHandler" from my jsf-managedBeans I use:

      @EJB(mappedName="GroupHandler/remote")
      private GroupHandlerRemote groupHandler;


      (with this code in GroupHandler:
      public static final String RemoteJNDIName = GroupHandler.class.getSimpleName() + "/remote";
      )

      That works.
      If I now want to inject a sessionbean from another sessionbean it does not work:

      <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3> ->
      ** UNRESOLVED Demands 'jndi:GroupHandler/remote' **


      I also tried
      @EJB() private GroupHandlerRemote groupHandler;

      without success.

      Can anyone tell me please how to inject my sessionbean?

      Thanks, NSchweig


        • 1. Re: How to inject sessionbean from sessionbean
          jaikiran pai Master

          Please post the entire exception stacktrace and even the console logs. Which version of JBossAS and Java do you use? And are those EJBs part of the same deployed application?

          • 2. Re: How to inject sessionbean from sessionbean
            Nicole Schweighardt Novice

            Hi,

            the only thing I see in the server.log that belongs to that error is:

            ...
            2009-01-03 10:27:14,656 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
            
            *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
            
            jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3
             -> <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3>{Described:** UNRESOLVED Demands 'jndi:CMT_ejb/de.cmt.beans.groupAdministration.GroupHandlerRemote' **}
            
            jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=GroupHandler,service=EJB3
             -> <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=GroupHandler,service=EJB3>{Described:** UNRESOLVED Demands 'Class:de.cmt.beans.courseAdministration.CourseHandlerRemote' **}
            
            
            *** CONTEXTS IN ERROR: Name -> Error
            
            <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=GroupHandler,service=EJB3> -> ** UNRESOLVED Demands 'Class:de.cmt.beans.courseAdministration.CourseHandlerRemote' **
            
            <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3> -> ** UNRESOLVED Demands 'jndi:CMT_ejb/de.cmt.beans.groupAdministration.GroupHandlerRemote' **
            
            
            2009-01-03 10:27:14,656 DEBUG [org.jboss.bootstrap.microcontainer.ServerImpl] (main) Installing life thread Thread[JBossLifeThread,5,jboss]
            ...
            


            (CourseHandler tries to inject groupHandler and vice versa)

            In the console it is the following:


            10:27:14,656 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
            
            *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
            
            jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3
             -> <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3>{Described:** UNRESOLVED Demands 'jndi:CMT_ejb/de.cmt.beans.groupAdministration.GroupHandlerRemote' **}
            
            jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=GroupHandler,service=EJB3
             -> <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=GroupHandler,service=EJB3>{Described:** UNRESOLVED Demands 'Class:de.cmt.beans.courseAdministration.CourseHandlerRemote' **}
            
            
            *** CONTEXTS IN ERROR: Name -> Error
            
            <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=GroupHandler,service=EJB3> -> ** UNRESOLVED Demands 'Class:de.cmt.beans.courseAdministration.CourseHandlerRemote' **
            
            <UNKNOWN jboss.j2ee:ear=CMT_ejb.jar,jar=CMT_ejb.jar,name=CourseHandler,service=EJB3> -> ** UNRESOLVED Demands 'jndi:CMT_ejb/de.cmt.beans.groupAdministration.GroupHandlerRemote' **
            
            


            I use JBoss 5.0.0 CR2 and jdk1.5.0_14

            The EJBs are part of the same application; they are only in separat packages:
            CMT_ejb.jar\de\cmt\beans\groupAdministration
            CMT_ejb.jar\de\cmt\beans\courseAdministration


            Thanks, NSchweig

            • 3. Re: How to inject sessionbean from sessionbean
              jaikiran pai Master

               

              CourseHandler tries to inject groupHandler and vice versa


              You mean a circular dependency? Try adding @IgnoreDependency on one of the injections. See this for detatils http://www.jboss.com/index.html?module=bb&op=viewtopic&t=117943

              • 4. Re: How to inject sessionbean from sessionbean
                Nicole Schweighardt Novice

                Yeah! :-) Thats it. Thank you very much.

                Best regards, NSchweig

                • 5. Re: How to inject sessionbean from sessionbean
                  Nicole Schweighardt Novice

                  For other people who are interested:

                  Thats the code in the groupHandler now:

                  @IgnoreDependency
                  @EJB() private CourseHandlerRemote courseHandler;


                  And thats it in the courseHandler:
                  @EJB() private GroupHandlerRemote groupHandler;