2 Replies Latest reply on Sep 18, 2002 7:39 PM by Ryan Delano

    JBOSS JNDI InitialContext

    Cory Wilkerson Newbie

      My other post was sooooo poorly named (on accident) that I've reposted under a relevant name. If this is taboo, I apologize...

      Here is my qusetion:

      When I retrieve the InitialContext in JBOSS, what context am I in at that point? Am I already in java:comp/env/ejb? I'm having to perform JNDI lookups on my beans as "HotelSessionHome" (or whatever home interface) and it just seems to me that I should be looking them up in the java:comp/env/ejb context. Am I missing something here? Perhaps I'm confused as to what context my beans are deployed in.

      Additionally, we have Resin integrated with JBOSS and home interfaces are resolved as "java:comp/env/ejb/HotelSessionHome"...why is this only available to clients and not to the container itself.

      I'm essentially wanting to abstract lookup functionality between the containers and I'd like to be able to reference the home interfaces under the same context...java:comp/env/ejb/BeanName.

      Lastly, is this functionality consist in 3.0 as we plan a migration soon?

      Thanks and please advise...
      Cory Wilkerson

        • 1. Re: JBOSS JNDI InitialContext
          Ryan Delano Newbie

          I see this question "got no love" so I figured I'd take a stab at it. : )

          Based on my observations, you start out with access to "java:/comp/env" The /ejb is definitely not a given and it's use depends on your deployment descriptor. This may only work for LOCAL interfaces but in my last project I was able to connect to my home interface with no prefix at all:

          x = (UserLocalHome)jndiContext.lookup("UserLocal");

          In another case I used the equiv. of "java:/come/env/UserLocal"

          If you need specifics on the deployment descriptor let me know and I can dig deeper with a better example.

          Good luck,

          • 2. Re: JBOSS JNDI InitialContext
            Ryan Delano Newbie

            I posted a reply to this earlier (that has not yet appeared in this thread). Since then I found an answer that was less speculative in the O'Reilly JBoss 3.0 Workbook by Bill Burke and Sacha Labourey.

            Since I already manually paraphrased what he says there (I tried to post this message and it got completely lost) I'm gonna be very brief since I hate typing stuff twice due to computer-suckage.

            Basically JBoss uses the <ejb-name> as the default binding to the HOME interface. (This tag goes in a jboss.xml file, see the thread I'll reference below or any number of other examples of how to write and where to place jboss.xml.) If you want to specify your own you can use a <jndi-name> entry just below the <ejb-name> entry in jboss.xml. So if you wanted your bean to show up in java:/comp/env/ejb/MyBean you should be able to use <jndi-name>ejb/MyBean</jndi-name>, otherwise just plan on using "MyBean" as it is the default. My first posting demonstrates this as a JDNI lookup more clearly. I'm sure it will appear on your thread within a few hours if it hasn't already.

            I recommend both the Workbook and the book to which it is a companion. Please view this thread:
            http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ to download the book and learn more.

            good luck,