I don't see anything wrong with that. I'd still like to eventually create a plugin that removes the need to do that in your execute method. The EJB spec added those annotations, so I'd like to figure out a way to honor them (cleanly).
-Wes On Wed, Jul 15, 2009 at 10:37 AM, Robin Mannering<ro...@mtndesigns.co.uk> wrote: > Hi Wes, > > I found a resource on the web that seems to be a simpler solution: > > InitialContext ic = new InitialContext(); > UserServiceBeanLocal userService = (UserServiceBeanLocal) > ic.lookup(UserServiceBeanLocal.class.getName()); > > As in the web resource I found, it was necessary to change @Local to @Remote > in the session bean for it to be found correctly. > > It worked perfectly using the above. > > Here is a link to the resource. What do you think of this solution? > > http://www.coderanch.com/t/58279/Struts/Connecting-ejb-session-bean-from > > Thanks > Robin > > Wes Wannemacher wrote: >> >> You are right, there is only one, the other one in that list is a >> jboss-ejb plugin. Take a look at the source for the plugin, it is not >> particularly complex and I know the author is lurking around here >> somewhere. I would suggest that you do one of two things - >> 1. Create an interceptor, probably identical to the one in the plugin. >> If you have troubles, bring them to the list, we'll help. >> 2. Create an object factory implementation that creates actions using >> your container's semantics. Again, if you have troubles, bring 'em >> back here, we'll help you. >> >> -Wes >> >> On Wed, Jul 15, 2009 at 9:48 AM, Robin Mannering<ro...@mtndesigns.co.uk> >> wrote: >> >>> >>> 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 >>>> >>>> >>>> >> >> >> >> ------------------------------------------------------------------------ >> >> >> 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 >> >> > -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org