6 Replies Latest reply on Mar 12, 2008 9:54 AM by Olivier Thierry

    How to retrieve an EJB from a JAR used in many EAR ?

    Olivier Thierry Apprentice


      I work with EJB3 (I am a newbie) and I have problems about state of the art way to retrieve an EJB from a JAR that will be used on many EAR projects.

      I have the following EJB (generated from AndroMDA) :


      My JAR contains Seam pojo classes that need to retrieve this EJB. I could do it this way :

      protected ServiceAbsenceRemote getServiceAbsence() throws Exception
       if (this.serviceAbsence == null) {
       InitialContext initialContext = new InitialContext();
       this.serviceAbsence = (ServiceAbsenceRemote)
       return this.serviceAbsence;

      As you can see, the problem is that I need to prefix the EJB name with the EAR name. If I don't do that I have a "ServiceAbsenceBean" not bound message. So it looks like this JAR can be used only in one EAR and I ask myself how it could work in another EAR ?

      I am sure I do something wrong, so please tell me ;)

      Thanks in advance