wood burning stoves*
The moose likes Struts and the fly likes Connecting to ejb 3 session bean from struts 2 ActionSupport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Connecting to ejb 3 session bean from struts 2 ActionSupport" Watch "Connecting to ejb 3 session bean from struts 2 ActionSupport" New topic
Author

Connecting to ejb 3 session bean from struts 2 ActionSupport

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
How do I get a reference to an ejb 3 local session bean from a struts 2 ActionSupport subclass?

E.g. is injection possible?

I did try to inject but got null.

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In theory, you're supposed to be able to use the @EJB annotation in a web client. In practice, most web containers don't support it. The best way I know of to get an EJB3 reference that works fairly consistently is:


Merrill
Consultant, Sima Solutions
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Like the other variations I tried with lookups, it also threw exception on that statement.



Just to note that when using servlet without struts, the annotation works. But now I need to use the session bean inside struts ActionSupport.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'd suggest reading this link from the WAS 6.1 Infocenter.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Originally posted by Merrill Higginson:
In theory, you're supposed to be able to use the @EJB annotation in a web client. In practice, most web containers don't support it. The best way I know of to get an EJB3 reference that works fairly consistently is:


Thank you for the link. It helped clear things up.

And thanks, the code you gave above worked! (after I changed @Local to @Remote in session bean.

For why WAS wants it like that is another mystery; but good enough for now for my purpose.

The injection @EJB still didnt work; but anyway I have that code above to get the bean.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'm glad you got it working.

Just for the record, according to the link I gave you, it should still be possible to use the local interface if you append "ejblocal:" to the beginning of the lookup name.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
Okay. I will try that out when I have time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting to ejb 3 session bean from struts 2 ActionSupport
 
Similar Threads
How to integrate hibernate and EJB (stateless session bean)
slow WAS 6.1 in RAD
Stateful and Stateless Session Bean reversed in JBoss?
displaying data - reuse
the Stateful and Stateless Bean in JBoss is reversed?