geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "NATARAJAN Sasi Kumar" <>
Subject RE: Local Session Bean lookups and JNDI
Date Fri, 17 Jun 2005 07:49:33 GMT
		      Context ctx = getInitialContext();
		      Object obj = ctx.lookup("SampleNameJNDI");
		      home = (SampleHome)



-----Original Message-----
From: Neal Sanche [] 
Sent: Friday, June 17, 2005 10:03 AM
Subject: Re: Local Session Bean lookups and JNDI

Hi Again Aaron,

You're right, that does work, thanks. From that, I'll see if I can 
figure out how to back-track and get XDoclet to generate something that 
will work in this case. I think I should be able to. But I have a 
fallback position anyway.



Aaron Mulder wrote:

>	It sounds like PhoneBookSessionUtil is trying to look up the
>	When really, based on the EJB ref you created, it should be 
>looking up:
>	There might be another method or constant in
>that you can use to achieve this.  Otherwise, just do this:
>PhoneBookSessionLocal session = ((PhoneBookSessionHome)
>     ctx.lookup("java:comp/env/ejb/PhoneBookSessionLocal")).create();
>	If you get that working, you can forget about the jndi-name and
>local-jndi-name (they won't be necessary unless you have an application
>On Thu, 16 Jun 2005, Neal Sanche wrote:
>>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
>>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
>>need for specifying the jndi-name and local-jndi-name for my CMP 2
>>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
>>another container I've used before. But I think maybe there's more to
>>in Geronimo? I can't do Local JNDI lookups and instantiate my EJBs
>>I used to be able to?
>>Do I need something in the geronimo-jetty.xml deployment plan file?
>>I have in my web.xml looks like this:
>>   <ejb-local-ref >
>>      <ejb-ref-name>ejb/PhoneBookEntryLocal</ejb-ref-name>
>>      <ejb-ref-type>Entity</ejb-ref-type>
>>      <local>org.acme.phonebook.ejb.PhoneBookEntryLocal</local>
>>      <ejb-link>PhoneBookEntry</ejb-link>
>>   </ejb-local-ref>
>>   <ejb-local-ref >
>>      <ejb-ref-name>ejb/PhoneBookSessionLocal</ejb-ref-name>
>>      <ejb-ref-type>Session</ejb-ref-type>
>>      <local>org.acme.phonebook.ejb.PhoneBookSessionLocal</local>
>>      <ejb-link>PhoneBookSession</ejb-link>
>>   </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]
>>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
>>can get it working, I don't care what it looks like. But, when I try
>>following code, Geronimo does this:
>>    public Collection getEntries() {
>>        try {
>>            InitialContext ctx = new InitialContext();
>>            PhoneBookSessionLocal session = 
>>            Collection c = session.listEntries();
>>            return c;
>>        } catch (Throwable ex) {
>>            System.err.println(ex);
>>            ex.printStackTrace();
>>        }
>>        return new ArrayList();
>>    }
>>javax.naming.NameNotFoundException: org.acme.phonebook.ejb
>>javax.naming.NameNotFoundException: org.acme.phonebook.ejb
>>        at 
>>        at 
>>        at javax.naming.InitialContext.lookup(
>>        at 
>>        at 
>>        at
>>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,
>>         else
>>            return objRef;
>>      } finally {
>>         initialContext.close();
>>      }
>>   }
>>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
>>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.

Confidentiality Statement:

This message is intended only for the individual or entity to which it is addressed. It may
contain privileged, confidential information which is exempt from disclosure under applicable
laws. If you are not the intended recipient, please note that you are strictly prohibited
from disseminating or distributing this information (other than to the intended recipient)
or copying this information. If you have received this communication in error, please notify
us immediately by return email.

View raw message