2 Replies Latest reply on Mar 24, 2004 4:47 AM by ahardy66

    JNDI naming for EJBs

    ahardy66

      I am trying to figure out the exact nature of the JNDI environment with regard to EJBs, JNDI names, initial contexts, local and remote settings, JVMs and networking.

      I've got my stuff working but I would like to make sure I'm correct.

      I have 2 EJBs. A stateless session facade and an entity. In my JBoss.xml I give them the JNDI names ejb/AdamsFacade and ejb/AdamsEntity

      The remote client calls up the facade by initializing the InitialContext with a hashmap containing a value for the provider url of 'jnp://localhost:1099'

      Then the remote client does this to get the RemoteHome:

      initContext.lookup("ejb/AdamsFacade")



      If my client was a servlet in a webapp running in an embedded tomcat, I don't have to initialize my InitialContext with anything, do I? I can then just get my RemoteHome by the following:

      initContext.lookup("java:/comp/env/ejb/AdamsFacade")


      Correct me if I'm wrong?! I didn't get it to work. Does it make a difference if the war is packaged in an ear with the EJBs or can it still do this when deployed seperately?

      Also, am I right in assuming these JNDI principles are J2EE standard?

      Thanks,
      Adam

        • 1. Re: JNDI naming for EJBs
          starksm64

          In order for a web client to be able to use initContext.lookup("java:/comp/env/ejb/AdamsFacade"), it has to define an ejb-ref or ejb-local-ref in its web.xml descriptor. If the war is in an ear with the target ejbs this can also specify the ejb-link to complete the binding. Otherwise, the ref must be made using the jboss-web.xml descriptor.

          This is standard j2ee stuff.

          • 2. Re: JNDI naming for EJBs
            ahardy66

            Great, thanks for info.

            One more Q: is there a big performance hit if I initialize my context with the external form "localhost:1099" when it's not necessary?