You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Dan Meany <da...@yahoo.com> on 2005/12/09 20:34:58 UTC

EJB global JNDI entries

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);
    	}
    }



Re: EJB global JNDI entries

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
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 <da...@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);
>         }
>     }
>
>
>