ejb@glassfish.java.net

JNDI Lookup in JSP fails for EJB 3.0

From: Rama Dinavahi <rdinavahi_at_gmail.com>
Date: Fri, 5 Jan 2007 23:01:48 -0500

Hi

I am new to Java technology. However, I read the EJB FAQ, NetBeans docs and
may forum discussions and I am still confused with the error I am having.

Background:
I have developed a persistence bean and related sessions beans (similar to
the customer-cmp-ear application in the Java App Server samples). Now I am
trying to access this bean using a JSP. After deploying the war file in the
App Server and try to access the page, I get the following error.

javax.naming.NameNotFoundException: No object bound to name
java:comp/env/ConsumerSessionLocal

After reading many articles, I understood that I *don't *have to prepare any
descriptors, or JAR files for EJB 3.0.

*Environment Details:*
Java App Server Ver 9.0
NetBeans 5.5
I normally build the war files using NetBeans.
I use App Server Admin console to deploy the web applications using the
above war file.

*EJB details:*
Persistence EJB : person.java

*Session Objects*
Consumer.java (this implements ConsumerSessionLocal, ConsumerSessionRemote).
This Stateless bean accesses the methods in person.java.
ConsumerSessionLocal.java - local interface
ConsumerSessionRemote.java - remote interface

*SearchConsumer.jsp*
This JSP page is calling the ConsumerSessionLocal using the JNDI lookup
through InitialContext.
Here is the Code snippet:
.........
try {
        InitialContext ic = new InitialContext();
        Object o = ic.lookup("java:comp/env/ConsumerSessionLocal");
        ConsumerSessionLocal consSession = (ConsumerSessionLocal) o;
...........

I am able to see the jsp page in the browser, however, after a submit
action, I get the Java Naming Exception error.

javax.naming.NameNotFoundException: No object bound for
java:comp/env/ConsumerSessionLocal

I would appreciate your help/any of your thoughts. I am not sure what I am
missing.

Thanks in advance.
Regards,
-Ram