File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Method call on session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Method call on session bean" Watch "Method call on session bean" New topic

Method call on session bean

Kanu Dialani

Joined: Apr 30, 2005
Posts: 23
I am calling a session bean from a MDB. The MDB gets a component Object stub and calls two methods on the same stub. I just wanted to know whether both the calls will go to a single session bean or it may happen that the first method is called on 1 session bean and the other method is called on another session bean as there is a pool of session beans.

If this is a poor design, should i combine the methods in session bean and call a single method from my MDB.

Please help...
Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108

The answer depends on whether you are using a stateless session bean or a statefull one.

If Statefull then yes the two methods will be called on the same bean.
If Stateless then it cannot be guaranteed that the same bean will be used for both method calls - the container manages the beans and it may give the client the same bean or a differenct one.


Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276


Please click on the My Profile link above and change your display name to meet the JavaRanch Naming Policy of using your real first and real last names.



Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Method call on session bean
It's not a secret anymore!