If your client is a J2EE application client that runs in our client
container, you need to configure it with an EJB reference in
application-client.xml and then resolve that to the specific EJB in
geronimo-application-client.xml. That way your client code will have
access to a java:comp/env JNDI environment and the EJB reference will
live in there.
If the client does *not* run in the client container, then you should
try looking up the EJB without the "java:comp/env/" prefix, so I would
have expected ctx.lookup("ejb/helloworld-ejb/HelloBean"); to work. If
it still does not, could you post the exception?
Thanks,
Aaron
On 11/23/05, Siraj Mohamed <[EMAIL PROTECTED]> wrote:
>
>
>
> Thanks Rakesh and Manu for your information. Now my look up doesn't work and
> it throws an exception NamingException:
> /java:comp/env/ejb/helloworld-ejb/HelloBean not found.
>
>
>
> My openejb-jar.xml referes jndi name as
>
>
>
> <enterprise-beans>
>
> <session>
>
> <ejb-name>HelloBean</ejb-name>
>
> <jndi-name>ejb/helloworld-ejb/HelloBean</jndi-name>
>
> </session>
>
> </enterprise-beans>
>
>
>
> And I am trying looking up it in my client class as:
>
> Object homeObject = ctx.lookup("java:comp/env/ejb/helloworld-ejb/HelloBean");
>
>
>
> I also tried with different options like:
>
> Object homeObject = ctx.lookup("ejb/helloworld-ejb/HelloBean"); or
>
> Object homeObject = ctx.lookup("HelloBean");
>
>
>
> Either one did not work.
>
>
>
> Am I missing some thing else?
>
>
>
> Thanks,
>
> -Siraj
>
>
>
>
>
>
>
>
>
> ________________________________
>
> From: Ranjan, Rakesh (Cognizant) [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 23, 2005 6:17 PM
> To: [email protected]
> Subject: RE: EJB JNDI lookup
>
>
>
>
> You have not specified the system properties to get the InitialContext.
>
> Use the following code to get the InitialContext.
>
>
>
> Properties props = new Properties();
>
> props.put("java.naming.factory.initial","org.openejb.client.RemoteInitialContextFactory");
>
> props.put("java.naming.provider.url", "127.0.0.1:4201");
>
> props.put("java.naming.security.principal", "system");
>
> props.put("java.naming.security.credentials", "manager");
>
>
>
> javax.naming.InitialContext ctx = new javax.naming.InitialContext(props);
>
>
>
> With Regards,
>
> Rakesh Ranjan
>
>
>
>
>
> ________________________________
>
> From: Siraj Mohamed [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 23, 2005 4:05 PM
> To: [email protected]
> Subject: EJB JNDI lookup
>
>
>
> Hi All,
>
>
>
> I have deployed a hello world application (helloworld.ear) on Geronimo 1.0
> M5. I have written a java client class to test my application. But I am
> getting following error message from the client code:
>
>
>
> NamingException: Need to specify class name in environment or system
> property, or as an applet parameter, or in an application resource file:
> java.naming.factory.initial
>
>
>
> It tells that I have to set java.naming.factory.initial and
> java.naming.provider.url in the jndi.properties. What would be the values to
> be specified for them for Geronimo server?
>
>
>
>
>
> This is my sample client code:
>
>
>
> /*
>
> * A simple client for accessing an EJB.
>
> */
>
>
>
> public class HelloClient
>
> {
>
> public static void main(String[] args)
>
> {
>
> System.out.println("client started...");
>
> try {
>
> javax.naming.Context ctx = new javax.naming.InitialContext();
>
>
>
> // This is for use with
> com.evermind.server.ApplicationClientInitialContextFactory
>
> System.out.println("looking up...");
>
> Object homeObject = ctx.lookup("java:comp/env/HelloBean");
>
>
>
> // Narrow the reference to HelloHome
>
> HelloHome home =
>
> (HelloHome) PortableRemoteObject.narrow(homeObject,
> HelloHome.class);
>
>
>
> // Create remote object and narrow the reference to Hello.
>
> Hello remote =
>
> (Hello) PortableRemoteObject.narrow(home.create(), Hello.class);
>
>
>
> System.out.println(remote.sayHello("James Earl"));
>
>
>
> } catch(NamingException e) {
>
> System.err.println("NamingException: " + e.getMessage());
>
> } catch(RemoteException e) {
>
> System.err.println("RemoteException: " + e.getMessage());
>
> } catch(CreateException e) {
>
> System.err.println("FinderException: " + e.getMessage());
>
> }
>
> }
>
> }
>
>
>
>
>
> Thanks in advance,
>
>
>
> -Siraj
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged information.
> If you are not the intended recipient, please contact the sender by reply
> e-mail and destroy all copies of the original message.
> Any unauthorized review, use, disclosure, dissemination, forwarding,
> printing or copying of this email or any action taken in reliance on this
> e-mail is strictly
> prohibited and may be unlawful.
>
> Visit us at http://www.cognizant.com
>