File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Local EJB lookup problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Local EJB lookup problem" Watch "Local EJB lookup problem" New topic

Local EJB lookup problem

Gavi Raaghav
Ranch Hand

Joined: Apr 28, 2005
Posts: 82
I have created a local stateless ejb using WSAD5.1.2
The default jndi name given by WSAD is ejb/com/gaurav/MyEJBLocalHome.
I am using the following line of code for lookup:
InitialContext ctx = new InitialContext();
MyEJBLocalHome home = (MyEJBLocalHome)ctx.lookup("java:comp/env/ejb/com/gaurav/MyEJBLocalHome");

It throws the following error during lookup:
[7/9/05 20:06:18:965 IST] 52b56f8c SystemErr R javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: ejb/com/gaurav/MyEJBLocalHome: First component in name ejb/com/gaurav/MyEJBLocalHome not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL

I have tried looking up the ejb by this jndi name through the UTC but i get the same error. Prefixing java:comp/env also gives me an error.

What is the problem,where am i going wrong.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

An undocumented featured of WSAD is that it adds local:ejb to the beginning of the JNDI name.

So if your remote JNDI name is "ejb/MyBean", the local one is "local:ejb/ejb/MyBean."

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Local EJB lookup problem
jQuery in Action, 3rd edition