Null EJB reference injdected in web client

Hi all,

I am confused about EJB dep. injection with web clients - maybe someone could shed some light on this please?

1. In the JEE 5 tutorial, the sample Converter App, the web client usesInitialContext.lookup to get references to the Converter EJB.

2. In the same tutorial, the sample DukesBank App, the web client uses@EJB dep. injection. For example, in the CustomerBean, AccountController is injected.

3. I've created a new Enterprise Application (using Netbeans 5.5) with a single stateless EJB and a web client. When injecting the EJB into a SERVLET, the reference is resolved, however when injecting the EJB into a STRUTS 2 ACTION, the reference in NULL :-(

Any ideas how to get a valid EJB reference using dep. injection in a struts action?

thanks.

[817 byte] By [sagmana] at [2007-11-27 6:57:08]
# 1

Hi sagman,

In Java EE 5 only certain managed classes have required support for environment annotations.

Java EE doesn't have any special notion of a Struts Action class.It's just considered a supporting

class that is not specially managed by the web container.So, you'll need to either explicitly pass

any resources/dependencies into the Action class or use a lookup. Here's an EJB FAQ entry that

shows a way to do that without using web.xml :

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB

--ken

ksaksa at 2007-7-12 18:34:19 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...