geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Mulder <ammul...@alumni.princeton.edu>
Subject Re: EJB global JNDI entries
Date Fri, 09 Dec 2005 19:43:43 GMT
Geronimo does not have a "global JNDI space" that's available to
server-side components.  You'll need to declare EJB references to
access EJBs within the server.  Application clients that do not use
the application client container use JNDI plumbing to access EJBs, but
that's really the exception rather than the rule in Geronimo.

For what it's worth, you still don't need a Geronimo deployment
descriptor so long as referencer and referencee are in the same module
or EAR -- you can do it like this:

<ejb-ref>
    <ejb-ref-name>ejb/Foo</ejb-ref-name>
    ...
    <ejb-link>Foo</ejb-link> or <ejb-link>my-ejbs.jar#Foo</ejb-link>
</ejb-ref>

Then in your application code:

MyHome home = (MyHome)new InitialContext.lookup("java:comp/env/ejb/Foo");

Thanks,
    Aaron

On 12/9/05, Dan Meany <dan_meany@yahoo.com> wrote:
> I have an app that works in JBoss, WebSphere and
> Weblogic with the same .ear binary.  I am having
> trouble with Geronimo either not seeing or not
> publishing the session EJBs in JNDI.  There does not
> appear to be anything in the global JNDI tree.  With
> JBoss, I don't have to use any vendor-specific xml
> files and it creates some JNDI entries automatically
> for the EJBs.
>
> My test openejb-jar.xml looks like:
>
> <openejb-jar
>     xmlns="http://www.openejb.org/xml/ns/openejb-jar"
>
> xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
>
> xmlns:security="http://geronimo.apache.org/xml/ns/security"
>
> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment"
>     configId="myappj"
>     parentId="myapp"
>     >
>  <enterprise-beans>
>
>   <session>
>     <ejb-name>LoginEJB</ejb-name>
>     <jndi-name>LoginEJB</jndi-name>
>   </session>
>
> <!--  ... other beans deleted  -->
>
>  </enterprise-beans>
>
> </openejb-jar>
>
> I am attempting to print out the JNDI tree with this
> code (works with JBoss, but only one JMX item is
> returned for Geronimo):
>
> logger.debug("----- Contents of Global JNDI namespace
> -----");
> printjnditree("");
> logger.debug("----- Contents of 'java:' JNDI namespace
> -----");
> printjnditree("java:");
> logger.debug("----------------------------------------------");
>
>     private static void printjnditree(String ns) {
>         try {
>                 printjnditree(ns, new InitialContext(), "");
>         } catch (Exception e) {
>                 logger.error(e);
>         }
>     }
>
>     private static void printjnditree(String name,
> Context ctx, String indent) {
>         try {
>            NamingEnumeration n =
> ctx.listBindings(name);
>            while (n.hasMore()) {
>               try {
>                  Binding b = (Binding)n.next();
>                  String bname = b.getName();
>                  String clsname = b.getClassName();
>                  Class cls = b.getClass();
>                  Object o = b.getObject();
>                  logger.debug(indent + bname + "
> (class: "+clsname+")");
>                  if
> (clsname.equals("javax.naming.Context") || o
> instanceof javax.naming.Context) {
>                     if (!name.endsWith(":")) name =
> name + "/";
>                     printjnditree(name + bname, ctx,
> indent + "  ");
>                  }
>               } catch (Exception e) {
>                     //System.out.println(""+e);
>               }
>            }
>         } catch (Exception e) {
>                 //System.out.println(""+e);
>         }
>     }
>
>
>

Mime
View raw message