0 Replies Latest reply on Feb 25, 2011 12:16 PM by ibstmt

    Getting two @EJBs to work together

    ibstmt

      Consider the following two EJBs:




      @Stateful
      @Name("ejbOne")
      @Scope(ScopeType.CONVERSATION)
      public class EjbTwo {
      
      @EJB 
      EjbTwo ejbTwo;
      ....
      }
      
      public void doSomething() {
         ejbTwo.doSomethingElse();
      }







      @Stateful
      @Name("ejbTwo")
      @Scope(ScopeType.CONVERSATION)
      public class EjbOne {
      
      @Create
      public void load(){
      // initialize a bunch of stuff
      }
      
      public void doSomethingElse() {
      // do something
      }



      When my page loads, EjbOne is created properly, and EjbTwo is created.  My page also has some direct references to EjbTwo. For example:




      #{ejbTwo.whatever} 





      All of that works correctly. If my page calls methods in EjbOne, no problem. If it calls methods in EjbTwo, no problem. My problem is when my page tries to invoke the doSomething method on EjbOne, which in turn tries to call a method in EjbTwo:




      #{ejbOne.doSomething}



      If I trace the code, I'm in ejbOne.doSomething. If I then continue into ejbTwo.doSomethingElse, it seems to be a different instance of EjbTwo. All of the class variables are null, and it's definitely not the same instance as when my page references EjbTwo directly.


      What am I doing wrong?