geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neal Sanche <>
Subject Local Session Bean lookups and JNDI
Date Fri, 17 Jun 2005 03:24:13 GMT
Hi All,

Well, I'm working through the details for a Struts web app with an EJB 
back end, all being compiled with a Maven build script and just putting 
all of the pieces in place to have XDoclet 1.2.3 do much of the major 
gruntwork for the Struts-config.xml and the ejb-jar.xml and web.xml 
also. Lots of details, but most of them are coming together now.

But I'm stuck on the JNDI side of things, it seems. I've discovered the 
need for specifying the jndi-name and local-jndi-name for my CMP 2 EJB, 
and my Stateless Session Bean inside of openejb-jar.xml and I've 
confirmed that my changes are having an effect on the deployed 
application by looking at the Debug Console and clicking on my EJBs. I 
have also put entries in my web.xml to link them like I used to do with 
another container I've used before. But I think maybe there's more to it 
in Geronimo? I can't do Local JNDI lookups and instantiate my EJBs like 
I used to be able to?

Do I need something in the geronimo-jetty.xml deployment plan file? What 
I have in my web.xml looks like this:

   <ejb-local-ref >
   <ejb-local-ref >

My Debug Console looks something like the following:

JndiNames 	[PhoneBookEntry]
LocalJndiNames 	[org.acme.phonebook.ejb/PhoneBookEntryLocalHome]


JndiNames 	[org.acme.phonebook.ejb/PhoneBookSession/Home]
LocalJndiNames 	[org.acme.phonebook.ejb/PhoneBookSession/LocalHome]

for each of them. Yes, I know, I make strange names for my JNDI 
entries... but that's what XDoclet seems to do for me, and as long as I 
can get it working, I don't care what it looks like. But, when I try the 
following code, Geronimo does this:

    public Collection getEntries() {
        try {
            InitialContext ctx = new InitialContext();
            PhoneBookSessionLocal session = 
            Collection c = session.listEntries();
            return c;
        } catch (Throwable ex) {
        return new ArrayList();

javax.naming.NameNotFoundException: org.acme.phonebook.ejb
javax.naming.NameNotFoundException: org.acme.phonebook.ejb
        at javax.naming.InitialContext.lookup(
        at org.acme.phonebook.struts.PhoneList.getEntries(

XDoclet is generating the following method, which I've used for years 
without incident:

   public static org.acme.phonebook.ejb.PhoneBookSessionLocalHome 
getLocalHome() throws javax.naming.NamingException
      return (org.acme.phonebook.ejb.PhoneBookSessionLocalHome) 

   private static Object lookupHome(java.util.Hashtable environment, 
String jndiName, Class narrowTo) throws javax.naming.NamingException {
      // Obtain initial context
      javax.naming.InitialContext initialContext = new 
      try {
         Object objRef = initialContext.lookup(jndiName);
         // only narrow if necessary
         if (java.rmi.Remote.class.isAssignableFrom(narrowTo))
            return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
            return objRef;
      } finally {

and the constants that it's using are:

   public static final String 
   public static final String 

I guess I'm feeling a little blind these days, since working with 
another container I was always able to simply take a squint at the JNDI 
tree through a nice little JMX method. Is there a similar operation I 
can do with this Debug Console? Remember I'm using Geronimo HEAD for 
most of this (I guess it's time for another maven m:update though).

Thanks for any insights you can give on better using JNDI and bridging 
the gap between the Web application and the EJB world.



View raw message