Just to note, there has been some work in OpenEJB to make it so Struts objects can use Java EE injection like Servlets or JSF components can. Karan did the work, he might be able to give more detail.

-David

On Jul 30, 2009, at 6:16 AM, Wes Wannemacher wrote:

Sorry Robin, this is on my to-do list, but it's not something I'm
working on right this second. One thing that is holding me up is the
lack of knowledge of JEE. Is there a standard mechanism for creating
instances of EJB-hydrated objects? For instance, if you annotated a
field on a servlet with @PersistenceContext, the entity manager will
be populated on the servlet. Obviously this works because the app
server instantiates the servlet and the app server knows to do things
like this. Is it part of the spec(s) that there is a way to
instantiate objects, complete with dependencies injected? I know you
can get objects from the JNDI context, but would that mean that
objects retrieved need to be defined in JNDI? In the example with the
servlet and EM, the servlet is defined in the web.xml, not the JNDI
context... So, is there a place where I can read up on standard
instantiation with EE DI?

If it's not part of the standard, then, I still wouldn't mind building
something specific to the app server that you are using (provided it
is something I can get my hands on for free i.e. JBoss, OpenEJB). I
started looking into this when this came up a few weeks ago, but I
wasn't finding what I wanted so it got put off. If there is a way for
me to call into the app server's own instantiation w/ DI facilities,
writing this plugin would be a snap...

-Wes

On Thu, Jul 30, 2009 at 2:17 AM, Robin Mannering<ro...@mtndesigns.co.uk > wrote:
Just to clear up my actual question from the thread below as feedback has
run dry unfortunately.

Is there anybody working daily with Struts 2 and EJB 3.0?

If so, what is the best way to obtain local references to EJB 3 session
beans from within Struts 2 action classes?

Thanks for any thoughts on this subject.

Robin Mannering wrote:

Just wondering if the below thread has gone any further.

After creating another thread on the same subject at an earlier date, we
discussed using the EJB plugin here:

http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html

However, having started to use this plugin so that I can reference
stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a
javax.naming.NameNotFoundException.

However, reading from a book entitled "Pro EJB 3.0", the following
performance issues are mentioned in relation to using @Remote when @Local is
available.  Hopefully this link will work for you.


http://books.google.co.uk/books?id=fVCuB_Xq3pAC&pg=PA40&lpg=PA40&dq=Making+an+interface+remote+has+consequences&source=bl&ots=Bg9DdpVAWW&sig=vxrumZhYLhjmqbt6bdMJ96hrY7s&hl=en&ei=QIdtStuLC-WhjAf34KGeCw&sa=X&oi=book_result&ct=result&resnum=

So, the problem is :

How can we obtain references to EJB 3 session beans from within Struts 2
action classes?

I'd be very interested to hear your thoughts.

Thanks
Robin

Nathan Schulte wrote:

Wes Wannemacher <wesw <at> wantii.com> writes:


Seems to me that my idea to create an ObjectFactory based plugin ...
needs to


pick up some steam.


I only have one question for the EJB users out there... Do you guys need


Spring integration as well?

To answer your question, _I_ personally don't need Spring integration.
 I've
never used Spring, and for this project, it was too much overhead to
learn (on
top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from
what I
understand, it seemed like using it and S2 together provided duplicate
functionality (another topic altogether...).

On another note, I find it awesome that the community (or whatever group
you're
part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's
just
that given my situation, it's easier to use the "workaround."
 Admittedly, I'm
not very familiar with JEE5. Some of this is still black magic, and I
don't
fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing
smoke my
way) and can leave all of the intricate details be, as they don't
directly
affect my project.

-Nate


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
270.13.20/2248 - Release Date: 07/19/09 05:57:00



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


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database:
270.13.31/2265 - Release Date: 07/26/09 17:59:00






--
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to