3 Replies Latest reply on May 31, 2006 7:52 AM by Louis Coetzee

    Circular injection problem

    Louis Coetzee Apprentice

      Hi,

      I ran across a very interesting problem with circular injection (and is looking for a better way to resolve it).

      I have two stateful session beans (A and B) . In A I do a

      @In(create=true) private B b
      while in B I inject A
      @In(create=true) private A a
      (Please dont ask why ;-)

      My impression is that when I call A, it injects B, which in turns injects A, which in turn injects B etc. until things go slightly wrong.

      I have resolved it by changing the injection of B (in A) to
      @In(create=false, required=false) private B b
      and then later (in the method where I actually need access to B from A) I do a
      b = (B)Component.getInstance("b",true);


      Any suggestions as to try and prevent this circular injection ?

      Thanks

      Louis