You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Hans Prueller <ha...@gmx.net> on 2005/11/24 16:13:57 UTC

JNDI Name not found...

hi again,

meanwhile I succeeded in deploying a little test .ear migrated from 
JOnAS to Geronimo. Now
I have a problem with the JNDI lookup of the beans on the web tier:

the JNDI name is defined in the geronimo deployment plan as follows:

 <enterprise-beans>
                <session>
                    <ejb-name>BusinessBean</ejb-name>
                    <jndi-name>BusinessHome</jndi-name>
                </session>
[ ... ]

the lookup is done like that:

BusinessHome h = null;
        try
        {
            h = (BusinessHome) PortableRemoteObject.narrow(ictx
                    .lookup("BusinessHome"), BusinessHome.class);
        }
        catch (NamingException e)
        {
            logger.log(Level.SEVERE, "cannot get bean home '"
                    + "BusinessHome" + "':" + e);
            addActionError("cannot_get_home");
        }

When I test the app, I get a cannot_get_bean_home error. Is there any 
prefix or something
else that I forgot? Or did I configure something wrong?

Any tips are appreciated!

regards,
Hans

-- 

*****
virtually hanzz... 
http://hanzz.zapto.org
***** 


Re: JNDI Name not found...

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
Hans,

Geronimo doesn't use JNDI names the way you're trying to use them. 
The only thing we use an EJB's JNDI name for is for remote clients to
access.  I'm assuming the lookup code you posted was from a web
component or something else running on the server side.  You should
declare an ejb-ref in your J2EE deployment descriptor, either with an
ejb-link there or with a Geronimo deployment plan that also contains
an ejb-ref and points to a specific ejb.  Then the lookup should use
the java:comp/env namespace.

So, for example:

<web-app
   ...
  <ejb-ref>
    <ejb-ref-name>ejb/BusinessHome</ejb-ref-name>
    ...
    <ejb-link>BusinessBean</ejb-link>
  </ejb-ref>
</web-app>

h = (BusinessHome) PortableRemoteObject.narrow(
    ictx.lookup("java:comp/env/ejb/BusinessHome"),
    BusinessHome.class);

As a side note, this method of using an ejb-ref and java:comp/env/
lookup will be portable across all J2EE servers, whereas as you've
discovered if you try to look up an EJB in the "global" JNDI name
space it will work on some and not work on others.

Thanks,
    Aaron

On 11/24/05, Hans Prueller <ha...@gmx.net> wrote:
>  hi again,
>
>  meanwhile I succeeded in deploying a little test .ear migrated from JOnAS
> to Geronimo. Now
>  I have a problem with the JNDI lookup of the beans on the web tier:
>
>  the JNDI name is defined in the geronimo deployment plan as follows:
>
>   <enterprise-beans>
>                  <session>
>                      <ejb-name>BusinessBean</ejb-name>
>                      <jndi-name>BusinessHome</jndi-name>
>                  </session>
>  [ ... ]
>
>  the lookup is done like that:
>
>  BusinessHome h = null;
>          try
>          {
>              h = (BusinessHome) PortableRemoteObject.narrow(ictx
>                      .lookup("BusinessHome"), BusinessHome.class);
>          }
>          catch (NamingException e)
>          {
>              logger.log(Level.SEVERE, "cannot get bean home '"
>                      + "BusinessHome" + "':" + e);
>              addActionError("cannot_get_home");
>          }
>
>  When I test the app, I get a cannot_get_bean_home error. Is there any
> prefix or something
>  else that I forgot? Or did I configure something wrong?
>
>  Any tips are appreciated!
>
>  regards,
>  Hans
>  --
>
> *****
> virtually hanzz...
> http://hanzz.zapto.org
> *****
>