1 Reply Latest reply on Jun 4, 2003 4:16 AM by Andrew

    EJB local reference

    Andrew Newbie

      Hello !
      I have two EAR files, and I want to make local reference from EJB in 1st EAR to EJB in 2nd EAR.

      I have 2 ways to do it by ejb-jar.xml:

      1. Write EJB name in <ejb-link> tag.
      <ejb-local-ref >
      <ejb-link>HIABean</ejb-link>
      </ejb-local-ref>

      But this works only if referenced EJB is in same EAR. I have a look to org.jboss.ejb.EjbUtil and, as far as I understand, it searched for given EJB-name by resolveAbsoluteLink method, starting search from "deployment info" of current EAR, and can"t find EJB that located in another EAR.

      2. Write relative path to JAR with deployed EJB then "#" and then EJB name in <ejb-link>
      <ejb-local-ref >
      <ejb-link>../../hia.ear/30.hia.ear-contents/hia.jar#HIABean</ejb-link>
      </ejb-local-ref>

      This works, but I should define path to deployed JAR, that contains some number (30 or 46, etc. I think this is number of deployed module) and if I redeploy 1st EAR - number can change and link to ear become incorrect.

      The questions are:
      1. Is all written above correct, and there is no another ways to make local reference?
      2. If it is really so, maybe org.jboss.ejb.EjbUtil can be modified to combine resolveAbsoluteLink and resolveRelativeLink to specify path to EAR file and EJB name to search, or make global search through all deployed EJB"s ?

        • 1. Re: EJB local reference
          Andrew Newbie

          ======================================
          * Forwarded by Sozonnik Andrew
          * From: "Christian Riege"
          * Date: Wed, 4 Jun 2003 09:26:25 +0200
          * To: "Sozonnik Andrew"
          * Subj: Re: Jboss question
          ======================================

          hi,

          On Tue, Jun 03, 2003 at 03:12:57PM +0300, Sozonnik Andrew wrote:
          >> I have two EAR files, and I want to make local reference from EJB in
          >> 1st EAR to EJB in 2nd EAR.

          according to the EJB specs there is no way to make a local reference
          between to EJBs contained in different .ear files. The only way to link
          them is by using a remote (by means of <ejb-ref> in the DD)
          reference.

          Local scoping only works when the EJBs are packaged in the same .ear file
          -- they may be in different .jar files in that .ear but they
          MUST be in the same .ear.

          >> [...]
          >> The questions are:
          >> 1. Is all written above correct, and there is no another ways to make
          >> local reference?

          see above. your approach of using <ejb-link> with a relative path sort of
          "works" but this is a) against the specs strictly speaking and
          b) not really supported -- i didn't even know that this works before you
          mentioned it in your mail :).

          >> 2. If it is really so, maybe org.jboss.ejb.EjbUtil can be modified to
          >> combine resolveAbsoluteLink and resolveRelativeLink to specify path
          >> to EAR file and EJB name to search, or make global search through all
          >> deployed
          >> EJB"s ?

          i don't think that this is a feasible approach to the problem.

          when you are deploying on JBoss, inter-EJB calls are optimized anyways,
          even if the EJBs are deployed in two different .ear files; even if you
          are "only" using remote interfaces.

          what you want would be a JBoss-specific 'enhancement' to the official
          spec and would basically make your .ear's undeployable on other vendors
          app-servers. stick with regular remote interfaces; this will make your
          application a) portable and b) as JBoss optimized the calls anyways (as
          long as the EJBs are running in the same VM), you won't get the usual
          penalty of using the remote interface to access the other EJB.

          hope this helps and best regards,
          christian