• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet JNDI Lookup SessionBean NameNotFound Exception

 
Rue Due
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please make ensure that User name once.


Cheers
Sudhakar Reddy.
k.V.r,Y.S.R,Y.S.Jagan
9989223696
 
Bhaskar Rao
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added a 'reference' for the bean in the web.xml where the Servlet is defined?
 
Pratheep Nair
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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";
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic