Meaningless Drivel is fun!*
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 Murach's Java Servlets and JSP this week in the Servlets 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
Author

Servlet JNDI Lookup SessionBean NameNotFound Exception

Rue Due
Greenhorn

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.


Cheers
Sudhakar Reddy.
k.V.r,Y.S.R,Y.S.Jagan
9989223696
Bhaskar Rao
Greenhorn

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
Greenhorn

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="
javax.naming.InitialContext,
javax.naming.Context"%>

<html>


<body>

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

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

aUser.setStatus(1);
%>

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";
 
 
subject: Servlet JNDI Lookup SessionBean NameNotFound Exception
 
Similar Threads
PLEASE, I need help with this..............
Configuring connetion pooling with tomcat 5.5
Help! Accessing EJB from Applet Error&#65281;
EJB Lookup problem on OC4J
Servlet Chaining