Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Stateless EJB3s in a Struts 2 application

 
Michael Ernst
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Michael Ernst
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For others who read this post: The name "MyBean" is a little bit confusing - better MyLocalInterface or MyRemoteInterface!

Regards
Michael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic