3 Replies Latest reply on Dec 12, 2002 10:16 AM by Marcus Schießer

    ejb reference bound in JNDIView, but not in bean context

    Marcus Schießer Newbie

      Hello to all...

      once again a stupid I don't know how to handle JNDI question. The reason why I ask it, is because I found no answer in the forum yet. So if there is one, sorry....
      I am using JBoss 3.0.3 and deployed some beans.
      One of the beans (UserSessionBean) has an ejb reference
      to ProductBean. (tried the problem with local and remote
      reference). JBoss seems to integrate the reference correctly, as the jndiview of the jmx console outputs
      the following:

      java:comp namespace of the UserSessionBean bean:

      +- env (class: org.jnp.interfaces.NamingContext)
      | +- ejb (class: org.jnp.interfaces.NamingContext)
      | | +- ProductLocalHome[link -> ProductBean] (class: javax.naming.LinkRef)

      Looks fine to me. But if I try to lookup the home of
      ProductBean with something like:

      Object obj = (new InitialContext()).lookup("java:comp/env/ejb/ProductLocalHome");
      (tried also only "ejb/ProductLocalHome")

      inside the UserSessionBean, it says that that name is not bound
      and yes, if i output the whole tree of the
      root context inside the bean i only get:

      ejb: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@1eef0a8
      mgmt: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@1f9e529
      MEJB: $Proxy14:ejb/mgmt/MEJBHome
      jmx: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@133e8c9
      ejb: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@f7e9dd
      Adaptor: $Proxy21:ejb/jmx/ejb/AdaptorHome

      but no ProductBean. So what am I doing wrong?
      Thanks for any help.



        • 1. Re: ejb reference bound in JNDIView, but not in bean context
          Joel Vogt Master

          whats your <ejb-ref-name>? Have you tried doing this lookup?

          • 2. Re: ejb reference bound in JNDIView, but not in bean context
            Marcus Schießer Newbie

            Hi, thanks for your reply.

            my <ejb-ref-name> is ejb/ProductLocalHome, therefore the one i used in the lookup...

            • 3. bug in JBoss?
              Marcus Schießer Newbie

              Hi to all,

              ok, now it get's really interessting. I played a bit more and realized the following:
              First I checked the jndiview source and realised that the jndi tree depends on the classloader used. So obviously, in my case the wrong classloader must be used, but why?
              If I try to print out the jndi tree in the ejbCreate method anything is fine, the ejb reference is included.
              But not if I use some private lookup method inside the bean.
              The problem I think is, that my session bean returns an instance of an anonymous class to the client. That anonymous class has access to the private lookup method and tries to uses it. Obviously, the class loader of the client is used in that case, because the ejb reference is not in the jndi tree. But at all, it's an method of the session bean and not of the client, so I think it should have access to the ejb reference.
              What do you folks think? Is this a bug of JBoss or is this behaviour intended in the J2EE reference?

              Cheers and thanks for any reply,