• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet JNDI Lookup SessionBean NameNotFound Exception

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you added a 'reference' for the bean in the web.xml where the Servlet is defined?
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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";
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic