This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Servlet JNDI Lookup SessionBean NameNotFound Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Servlet JNDI Lookup SessionBean NameNotFound Exception" Watch "Servlet JNDI Lookup SessionBean NameNotFound Exception" New topic

Servlet JNDI Lookup SessionBean NameNotFound Exception

Rue Due

Joined: Dec 16, 2006
Posts: 1
I am trying to lookup my session bean but it looks like it cannot find the jndi name.
I am using websphere and eclipse for development.

It doesn't work with the servlet. If I put this code in a console application, it works ok. Any idea?

Here is my code

Error Generated:

[ December 16, 2006: Message edited by: Rue Due ]
Sudhakar Reddy Kurakula
Ranch Hand

Joined: Aug 19, 2006
Posts: 42
please make ensure that User name once.

Sudhakar Reddy.
Bhaskar Rao

Joined: Apr 25, 2005
Posts: 23
Have you added a 'reference' for the bean in the web.xml where the Servlet is defined?
Pratheep Nair

Joined: Sep 20, 2005
Posts: 14
Websphere has its own ejb container. So I am not sure why you are using "org.openejb.client.RemoteInitialContextFactory" for the initial context when you are looking up the EJB from your servlet. It may be required for your java client because it doesn't have an InitialContext associated.
Try the following code from your servlet:

<%@ page import="



Context initial = new InitialContext();
Object homeRef=initial.lookup(JNDI_NAME);

UserHome home=(UserHome)PortableRemoteObject.narrow(homeRef,UserHome.class);
User aUser=home.create();


If you create an EJB reference within your web deployment descriptor, make sure you define your JNDI_NAME as:
private static final String JNDI_NAME="java:comp/env/WebUser";
I agree. Here's the link:
subject: Servlet JNDI Lookup SessionBean NameNotFound Exception
It's not a secret anymore!