permaculture playing cards*
The moose likes Struts and the fly likes Using Stateless EJB3s  in a Struts 2 application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using Stateless EJB3s  in a Struts 2 application" Watch "Using Stateless EJB3s  in a Struts 2 application" New topic
Author

Using Stateless EJB3s in a Struts 2 application

Michael Ernst
Greenhorn

Joined: Jul 03, 2005
Posts: 23
Hi,

my project contains of three (eclipse) project. One project contains all JPA files, the second contains the Stateless Session Beans (with all CRUD operations) and the least project contains the web (Struts 2) application. How can I combine the Actions with the beans without a lot of additional code (InitialContext etc.). Is there a way to get a reference via reference injection or what is the normal approach for this task?

Thanks in advance!

Regards
Michael
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
Michael Ernst
Greenhorn

Joined: Jul 03, 2005
Posts: 23
Thanks for your reply.
The InitialContext solution was also my first idea. The first idea is sometimes the best idea.

Regards
Michael
Michael Ernst
Greenhorn

Joined: Jul 03, 2005
Posts: 23
For others who read this post: The name "MyBean" is a little bit confusing - better MyLocalInterface or MyRemoteInterface!

Regards
Michael
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Stateless EJB3s in a Struts 2 application
 
Similar Threads
Bean import/reference problem [1/2 solved]
CMP vs BMP
Bundle lib in ejb jar doesn't deploy
Questions about the "EJB 3 in Action" book
Convert struts' Action class into stateless session bean ?