2 Replies Latest reply: Oct 15, 2007 3:46 PM by 807600 RSS

    calling one EJB form another EJB

    807597
      Hi,

      i have 2 EJBs (Session Beans). Inside first EJB in one of its methods, i have to call the second EJB's one method. What are the steps invlovled in this operation?

      Thanks
        • 1. Re: calling one EJB form another EJB
          807597
          It's the same as calling an EJB from a client application. I'm not very good at it, but as much as I know, you need to lookup for the EJB Home object using JNDI and obtain the Remote object from it. Then you can call all the methods on the Remote object.

          If the two EJBs reside in a different container, you would need to obtain a new InitialContext by passing the environment properties of the other container and then lookup as usual.

          The only precaution you need to take is that you need the EJB-client JAR (containing the home and remote interfaces only) for the other EJB available so that ClassNotFoundException and similar exceptions are not thrown.

          I hope I was helpful!

          Regards,
          UW
          • 2. Re: calling one EJB form another EJB
            807600
            Hi, I was having this exact same problem and was wondering if you had figured it out yet.

            Undead: could you go into more detail or give an example or something of what you mean. I have been stuck with a ClassCastException for about a week now and I would really appreciate it.