wood burning stoves 2.0*
The moose likes Websphere and the fly likes Urgent Help needed. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Urgent Help needed." Watch "Urgent Help needed." New topic

Urgent Help needed.

Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
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.

Siddharth Purandare<br />SCJP 1.4 - 76%<br />SCWCD 1.4 - 85%<br /> <br />It is the "attitude" and not the "aptitude" which determines "altitude".
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

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.

Hanumanth Kanthi
Ranch Hand

Joined: May 27, 2004
Posts: 74
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

Joined: Nov 13, 2006
Posts: 101
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

Joined: Nov 13, 2006
Posts: 101
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Urgent Help needed.
Similar Threads
Test Connection failed ( IBM Websphere 5.1 Express )
I got a NamingContextPackage.NotFound Exception
Error : WSVR0068E: Attempt to start EnterpriseBean
Remote EJB Access in WAS 5.1
problem defining URL resource