javajakarta-eeejbejb-3.0glassfish-3

EJB - Lookup failed for 'ejb/BookRequestBean'


I am new to EJB, and was trying "Hello World" type of EJB Java program. Here is my EJB:

package dukesbookstore.ejb;
@Stateless(name="BookRequestBean", mappedName="ejb/BookRequestBean")
@Named
public class BookRequestBean {
    //Other codes here
}

and here is my client:

    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
    prop.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    prop.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
    try {
        InitialContext ctx = new InitialContext(prop);                              
        ctx.lookup("ejb/BookRequestBean");
        System.out.println("EJB Look-up successfull!!");
    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But whenever I try to run, I am getting below exception:

javax.naming.NamingException: Lookup failed for 'ejb/BookRequestBean' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=localhost, java

I have added appserv-rt.jar , gf-client.jar, javaee.jar, but still no luck. Can anyone help me, what I am missing here? I am usign Glassfish 3.1


Solution

  • In addition to nice @RaviTrivedi answer, here are few thoughts: