users@glassfish.java.net

Re: _at_EJB annotation does not bind EJB under java:comp/env

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Tue, 16 Oct 2007 12:22:10 -0400

@EJB injects or declares a ejb-ref to the target component (e.g.,
servelt) that uses the EJB. From your code, it seems you are using @EJB
on the subject bean, which is not what you want.

-cheng

Vano Beridze wrote:
> Hello
>
> I user NetBeans 6 latest daily build, glassfish v2 b58g.
> I've created Enterprise Application Project in NetBeans with EJB
> Module project.
> I've created one stateless session bean in EJB Module Project with one
> simple method.
> I used @EJB annotation to register my EJB in ENC.
>
> package test;
>
> import javax.ejb.EJB;
> import javax.ejb.Stateless;
>
> @Stateless
> @EJB(name="ejb/EchoProvider", beanInterface=EchoProviderLocal.class)
> public class EchoProviderBean implements EchoProviderLocal {
>
> public String sayHello(String callerName) {
> return "Hello "+callerName;
> }
> }
>
> I've deployed the application successfully to glassfish.
> When I log in to http://localhost:4848 and go Application Server |
> JNDI Browsing, there is only one entry under ejb node that is ejb/mgmt
>
>
> Moreover I've created simple Web Application with one jsp page and a
> servlet. When a user clicks button in the browser, the request is sent
> to the servlet that calls the following code
>
> InitialContext ic=new InitialContext();
> Object obj=ic.lookup("java:comp/env/ejb/EchoProvider");
>
> after ic.lookup NamingException is thrown with the message that the
> name is not bound.
>