users@glassfish.java.net

Re: Debug _at_EJB (javax.ejb.EJB) annotation in Web Application

From: NBW <emailnbw_at_gmail.com>
Date: Mon, 16 Mar 2009 14:33:35 -0400

Local EJB injection is supported in POJOs - see the EJB 3 FAQ here:
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB

If you are trying to access a bean from your Web Service class via a
delegate POJO you can accomplish this by injecting the bean into the web
service class using class level injection like so:

@EJB(name="MyBean", beanInterface=com.MyModel.class, mappedName="MyBean")

Then in your POJO which is called by your web service you can instantiate it
in the constructor like so:


try { Context ctx = new InitialContext(); myBean = (MyModel)
ctx.lookup("MyBean"); } catch (NamingException e) { log.error( ""Error :
Failed to look up MyBean.", e);
}

myBean is a property of the POJO. If you are using Glassfish you will also
need to add the local EJB refs. to your web.xml.

Hope this is what you are looking for.


On Mon, Mar 16, 2009 at 2:01 PM, <glassfish_at_javadesktop.org> wrote:

> Injection is not supported in a POJO - check Java EE 5 spec for the list of
> the components where injection is supported.
>
> Regards,
> -marina
> [Message sent by forum member 'mvatkina' (mvatkina)]
>
> http://forums.java.net/jive/thread.jspa?messageID=337267
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>