This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a Ejb3.0 from a servlet

 
Padma Priya
Ranch Hand
Posts: 123
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Is it possible to call a sateless or stateful ejbb3.0 session bean from a servlet. If it possible could anyone please point me to a tutorial on this.

With Regards
Deepthi
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. This shows how to do it, but more application servers also come with example code.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul's tutorial is for EJB2.x You'll find an example of using a stateless session bean from a servlet in the Java EE 6 Tutorial.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh!
 
Padma Priya
Ranch Hand
Posts: 123
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have another doubt. If a request is sent to a servlet and this request is sent in a new thread. The servlet in turn calls another Ejb. So will the call to the Ejb take place in the same thread or another thread will be started.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is: perhaps, but probably not. You need to think "does it matter"? One of the reasons you use EJB containers is to delegate the threading behaviour to the container itself. If you are doing something that requires you use the same thread you are probably doing somthing wrong. Why do you need to use the same thread?
 
Padma Priya
Ranch Hand
Posts: 123
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks for the reply. It was actually an interview question and i answered by saying that the ejb container takes care of creating threads for Ejbs. Didn't know if i was right or wrong.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic