4 Replies Latest reply on Apr 20, 2004 11:33 PM by raja05

    ejb-local-ref question

    lshepherd

      i have a local reference to an entity bean declared in my session bean facade as so:

      <session >
       <description><![CDATA[ShorexFacade EJB]]></description>
       <display-name>ShorexFacade</display-name>
      
       <ejb-name>ShorexFacade</ejb-name>
      
       <home>com.hal.layne.interfaces.ShorexFacadeHome</home>
       <remote>com.hal.layne.interfaces.ShorexFacade</remote>
       <ejb-class>com.hal.layne.ejb.ShorexFacadeSession</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
      
       <ejb-local-ref >
       <ejb-ref-name>ejb/ShorexTour</ejb-ref-name>
       <ejb-ref-type>Entity</ejb-ref-type>
       <local-home>com.hal.layne.interfaces.ShorexTourLocalHome</local-home>
       <local>com.hal.layne.interfaces.ShorexTourLocal</local>
       <ejb-link>ShorexTour</ejb-link>
       </ejb-local-ref>
      
       </session>
      


      when i bind the local home interface for the entity bean to "java:comp/env/ejb/ShorexTourLocalHome" the local reference in the session bean doesn't work. but if i bind to the global JNDI namespace, it works fine.

      the session bean does the lookup as so:
      ctx = new InitialContext();
       Object ref = ctx.lookup("java:comp/env/ejb/ShorexTour");
      


      why doesn't it work when the entity's local home is bound in java:comp?

      also, is there a danger in exposing the local home interface in the globabl JNDI namespace? you'd think a remote client would be able to look it up and get a reference to it ...

      thanks,
      layne

        • 1. Re: ejb-local-ref question
          raja05

          Just checking, do you have your "ShorexTour"
          EJB named in the same ejb-jar.xml!
          Something like


          <ejb-name>ShorexTour</ejb-name>
          .....
          ...

          • 2. Re: ejb-local-ref question
            lshepherd

            Yes, the entity EJB is named "ShorexTour" in the deployment descriptor.

            I just wrote a test class that connects to the JNDI naming service from another JVM process. It successfully looked up the session facade and called it's methods. But when I tried to look up the local interface of the entity EJB, I got a naming exception. Which is good and what I was hoping would happen.

            My guess is that JBoss will not allow the lookup of the local interface from the outside. Just wondering how it knows.

            • 3. Re: ejb-local-ref question
              s5554

              I have made conclusions which poin to the same direction, listing Context.list("java:/comp/env") succeeds only in a servlet, when I try it from a java-client I get javax.naming.NameNotFoundException: comp not bound

              RL

              • 4. Re: ejb-local-ref question
                raja05

                Yes, java:comp/env is an internal representation. You cannot reference it from outside unless you have a client descriptor that resolves java:comp/env to java:/JNDIName(or whatever ur jndi is).

                Im not sure how much of a progress is made on the client side descriptors in j2ee1.4 but it sure was in earlier releases.