Many thanks for the prompt and detailed reply.

I understand why the use of injection does not work now within a Struts2 action class.

However, there only seems one EJB plugin available, which doesn't actually have a download available and hasn't had for some time it appears.

http://code.google.com/p/struts2ejb3/downloads/list

I'm wary to trust in a plugin that doesn't appear to be currently maintained (available to download).

Is there anybody that is using Struts2 as the 'frontend' to an EJB 3 'backend' and what solution do you currently employ.

Thanks
Robin

Wes Wannemacher wrote:
The difference is that the container did not instantiate your struts
action, struts did. There are EJB plugins available, check the plugin
registry.

http://cwiki.apache.org/S2PLUGINS/home.html

The ones I have seen are based on injection via interceptor. I've
toyed with the notion of creating an ObjectFactory based plugin so
that struts can delegate creation of action classes to the ejb
container. This would allow for injection for more than just @EJB
(@PersistenceContext comes to mind).

The only issue is that it doesn't seem like we see much traffic on
here from ejb users. Would anyone else be interested in an
ObjectFactory based plugin? If so, would any of you also want it to
work with Spring? The interceptor-based solution works good because it
doesn't interfere with object-creation-based plugins like
spring/guice/etc.

-Wes

On Wed, Jul 15, 2009 at 9:21 AM, Robin Mannering<ro...@mtndesigns.co.uk> wrote:
Hello,

Platform : Struts 2, EJB 3.0, Glassfish 2.1

I wish to obtain a reference to an EJB using injection.

This works fine within a servlet, but from within a Struts2 action class,
all references to injected EJB variables hold a 'null' reference.

I've included a portion of my action class below.

I'm confused as to why a Servlet has no trouble using injection as compared
to the Struts 2 action class.  Both the servlet and action class reside in
the same Web application.

Does anybody have any ideas?

/public class UserAction extends ActionSupport implements
ServletRequestAware, SessionAware {

  private static Logger logger = Logger.getLogger(SetupServlet.class);
    @EJB
  SetupServiceBeanLocal setupService;
    @EJB
  UserServiceBeanLocal userService;
...
}/




------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.14/2238 - Release Date: 07/14/09 18:03:00

Reply via email to