3 Replies Latest reply on Apr 16, 2003 9:45 AM by adrian.brock

    making EJB local references from two diffrent EARs

    cvulpe

      Hi all!

      My team and me are developing a J2EE application and we thought about the following procedure: separate the reusable components from the business logic components. To be more specific we separated EJBs like UUID string-based generators and general façade invokers into the reusable part of the thing (and we obtained an EAR). The business logic (EJBs that are updating and querying the database) is using those components and we have another EAR.

      The problem we have is: we don’t know (we don’t know even if it is possible) to obtain EJB local references (not EJB references that will produce slower RMI calls!) to the components from the first EAR (with reusable components). We would like to know how could we do that (I mention that we use JBoss 3.0.6 at this moment).


      Thanks a lot,
      Cristi

      PS: if you consider too ambiguous my problem, I will send more details.

        • 1. Re: making EJB local references from two diffrent EARs

          Outside of an ear you have to lookup into
          global jndi.
          By default the bean is at local/<ejb-name>

          Remote is optimized to local in the same
          jboss server.

          Regards,
          Adrian

          • 2. Re: making EJB local references from two diffrent EARs
            cvulpe

            Hi!

            I still have a few questions:
            1) The procedure you propose is a portable one over different EJB servers?
            2) Are there necessary any extra-settings into the deployment descriptors?
            3) If I have a bean whose JNDI name is "MyBean", can you give me a short example of the lookup code line?

            Thanks again,
            cristi

            • 3. Re: making EJB local references from two diffrent EARs

              No this is not portable.

              The j2ee spec does not include a mechanism
              for local references outside the application (ear)

              The example code is
              InitialContext ctx = new InitialContext();
              MyLocalHome home = (MyLocalHome) ctx.lookup("local/MyEJBName");

              I think most application servers let you redefine
              the global local jndi name
              e.g. in jboss.xml


              <ejb-name>whatever</ejb-name>
              <local-jndi-name>ejbs/local/whatever</local-jndi-name>
              ...

              Regards,
              Adrian