• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Urgent Help needed.

Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am new to EJB's and First time creating EJB's in Websphere Version: 5.1.2. I have created the bean project in the Websphere and written a method myMethod() in which I have written "Hello Bean".

This is running absolutely fine when I test the Bean with the websphere's own JNDI explorer and its giving me the message what I have written in myMethod().

The same thing when I tried to Run using 1. Servlet OR 2. JSP OR 3. Plain Java class with main() (I created the new dynamic web project)I am not getting the desired output and getting the error.

There are no compilation error in the code also the packaging and placing of Beans is not an issue because the websphere is itself creating everything.

***********Error in Running servlet is ************

[2/27/07 16:01:46:950 IST] 7b388473 WebGroup I SRVE0180I: [HelloWeb] [/HelloWeb] [Servlet.LOG]: Test: init
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: jndiname: First component in name jndiname not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:968)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:1399)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:3491)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1519)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067)
[2/27/07 16:01:47:294 IST] 7b388473 SystemErr R at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)

Let me know if you need any further help from my side I can provide the code of my Home/Remore/Implementation class But as I said everything is created by Websphere and there is no problem with the code as its running fine with its own JNDI explorer.

**************My EJB deployment descriptor is as below (This is created by Websphere)**********

<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">;
<ejb-jar id="ejb-jar_ID">
<session id="HelloBean">

Thanks in advance for any help.

PS: I have also added the class path entry in my dynamic project where my servlet/jsp is located.
author and cow tipper
Posts: 5000
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really shouldn't say 'urgent' in your message.

I'm not clear what your problem is. Are you saying that the code works with JNDI explorer, but not in a JSP or Servlet?

Here's a tutorial on JNDI naming with WebSphere:

JNDI Naming and Developing EJB Clients with WebSphere

This tutorial might provide some insight.

Good luck.

Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are getting NNF Exception means.... could be 2 possibilities:
1) Object that you are trying to look for might not be in the JNDI name space (OR)

2) The way you are looking up the Object might be entirely wrong.

Run dumpNameSpace.bat from WebSphere bin folder and see if you can find your object....

H. Kanthi
Siddharth Purandare
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cameron ,

Thanks for the help. YES I am able to run it via JNDI explorer but when I write the below code in servlet its throwing the exception.


public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

Context ic=new InitialContext();
Object o=ic.lookup("ejb/com/HelloBeanHome");
HelloBeanHome home=(HelloBeanHome) PortableRemoteObject.narrow(o,HelloBeanHome.class);
HelloBean rem=home.create();
}catch(Exception e){



[2/28/07 16:10:36:196 IST] 698fa86a WebGroup I SRVE0180I: [HelloWeb] [/HelloWeb] [Servlet.LOG]: Test: init
[2/28/07 16:10:36:586 IST] 698fa86a WebGroup E SRVE0026E: [Servlet Error]-[com.HelloBeanHome]: java.lang.NoClassDefFoundError: com.HelloBeanHome
at Test.doGet(Test.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
Siddharth Purandare
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks for all your help. I got the solution now. The web.xml of my web project and EJB deployment of my EJB project were not in sync with each other. I studied both the files and the related entries for <ejb-ref> in both the files was corrected by me to Run my First EJB application.

Thanks again.
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic