users@glassfish.java.net

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

From: Vano Beridze <vano.beridze_at_silkroad.ge>
Date: Wed, 17 Oct 2007 14:44:19 +0400

Cheng Fang wrote:
> @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.
Is it possible to register my bean in ENC context using some other
annotation?
Or I should use xml descriptor.
>
> -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.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>


-- 
Vano Beridze
Software Developer
Silk Road Group