File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes .NameNotFoundException: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark ".NameNotFoundException: " Watch ".NameNotFoundException: " New topic


hemapriya raag

Joined: Jul 09, 2007
Posts: 4
I am trying to run the project given in headfirst ejb 1 chapter by using netbeans where my client file is not able to recognise the bean by using JNDI
My client file is:
package adviceclient;
import Headfirst1.*;
import java.rmi.RemoteException;
import javax.ejb.EJB;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

public class Main {

private static Advice2Remote advice2Bean;
public static void main(String[] args) {
InitialContext ic = new InitialContext();
Object o=ic.lookup("ejb/Advice2Bean");
Advice2Home home=(Advice2Home)PortableRemoteObject.narrow(o,Advice2Home.class);
Advice2Remote advisor=home.create();
catch(Exception ex)

And errors are:

javax.naming.NameNotFoundException: Advice2Bean not found
at com.sun.enterprise.naming.TransientContext.doLookup(
at com.sun.enterprise.naming.TransientContext.lookup(
at com.sun.enterprise.naming.TransientContext.lookup(
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(

please some one help me.........
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Have you mapped your bean with its JDNI name?

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Sumit Malik
Ranch Hand

Joined: Jan 05, 2007
Posts: 84
Hi Hemapriya,

As mentioned by Freddy first ensure that ejb is associated jndi name "ejb/Advice2Bean" in your application server.

If you are using jboss you can view already deployed bean through jndiView service(of jmxConsole). Once you land up on service page then by clicking invoke button of view operation you would come to know which are the already deployed bean on your app server.

If you bean is listed there then you can call you bean with mentioned jndi name.

Cheers !!!
Sumit Malik

If at first you don't succeed, don't try skydiving
I agree. Here's the link:
subject: .NameNotFoundException:
It's not a secret anymore!