A couple things...
While possible you might not want to try to use a session bean in a jsp.
Instead use a servlet, take any data that you want to render and add it
to the request scope and then forward using a RequestDispatcher to a
jsp. Use usebean/EL/JSTL to display the data.
If your session bean is stateless then why are you using JNDI? Just use
dependency injection.
If you want to use JNDI then you'll have to setup some ejb references in
your web.xml for it to work.
-Chase
Rama Dinavahi wrote:
> 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 persistance 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 *dont *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:_
> Persistance 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 any of your thoughts.
>
> Thanks in advance.
> -Ram