geronimo-dev mailing list archives

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

<weblogic-ejb-jar>
  <weblogic-enterprise-bean>
    <ejb-name>statelessSample</ejb-name>
    <enable-call-by-reference>True</enable-call-by-reference>
    <jndi-name>SampleNameJNDI</jndi-name>
  </weblogic-enterprise-bean>
</weblogic-ejb-jar>

Cheers,
Sasikumar



-----Original Message-----
From: Neal Sanche [mailto:neal@nsdev.org] 
Sent: Friday, June 17, 2005 10:03 AM
To: dev@geronimo.apache.org
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.

Cheers.

-Neal

Aaron Mulder wrote:

>	It sounds like PhoneBookSessionUtil is trying to look up the
JNDI 
>name:
>
>org.acme.phonebook.ejb/PhoneBookSession/LocalHome
>
>	When really, based on the EJB ref you created, it should be 
>looking up:
>
>java:comp/env/ejb/PhoneBookSessionLocal
>
>	There might be another method or constant in
PhoneBookSessionUtil
>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
>client).
>
>Aaron
>
>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
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-ref-name>ejb/PhoneBookEntryLocal</ejb-ref-name>
>>      <ejb-ref-type>Entity</ejb-ref-type>
>>      
>><local-home>org.acme.phonebook.ejb.PhoneBookEntryLocalHome</local-home
>
>>      <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-home>org.acme.phonebook.ejb.PhoneBookSessionLocalHome</local-ho
me>
>>      <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]
>>
>>
>>and
>>
>>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 = 
>>PhoneBookSessionUtil.getLocalHome().create();
>>            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 
>>com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java
>>:95)
>>        at 
>>com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java
>>:103)
>>        at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>        at 
>>org.acme.phonebook.ejb.PhoneBookSessionUtil.lookupHome(PhoneBookSessi
>>onUtil.java:16)
>>        at 
>>org.acme.phonebook.ejb.PhoneBookSessionUtil.getLocalHome(PhoneBookSes
>>sionUtil.java:54)
>>        at
org.acme.phonebook.struts.PhoneList.getEntries(PhoneList.java:51)
>>
>>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) 
>>lookupHome(null, 
>>org.acme.phonebook.ejb.PhoneBookSessionLocalHome.JNDI_NAME, 
>>org.acme.phonebook.ejb.PhoneBookSessionLocalHome.class);
>>   }
>>
>>   private static Object lookupHome(java.util.Hashtable environment, 
>>String jndiName, Class narrowTo) throws javax.naming.NamingException {
>>      // Obtain initial context
>>      javax.naming.InitialContext initialContext = new 
>>javax.naming.InitialContext(environment);
>>      try {
>>         Object objRef = initialContext.lookup(jndiName);
>>         // only narrow if necessary
>>         if (java.rmi.Remote.class.isAssignableFrom(narrowTo))
>>            return javax.rmi.PortableRemoteObject.narrow(objRef,
narrowTo);
>>         else
>>            return objRef;
>>      } finally {
>>         initialContext.close();
>>      }
>>   }
>>
>>and the constants that it's using are:
>>
>>   public static final String 
>>COMP_NAME="java:comp/env/ejb/PhoneBookSessionLocal";
>>   public static final String 
>>JNDI_NAME="org.acme.phonebook.ejb/PhoneBookSession/LocalHome";
>>
>>
>>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.
>>
>>Thanks.
>>
>>-Neal
>>
>>
>>
>>    
>>

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.


Mime
View raw message