wood burning stoves
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes stateless vs stateful session beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "stateless vs stateful session beans" Watch "stateless vs stateful session beans" New topic

stateless vs stateful session beans

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 808

I have read that in case of stateful session bean - every invocation which is performed on the same proxy reference will be handled by the same bean instance. I wonder how it is possible.
In servlets cookies have to be enabled (or URL rewritting, or hidden fields) in order to maintain conversational state. But I have not encountered on such requirement in case of stateful session beans. It seems that is is held automagically . Can someone reveal this secret?


BLOG: http://leakfromjavaheap.blogspot.com
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3322
I am not sure about low level mechanism, but note: HTTPS does not need cookies to track the client (from servlet specifications), so I assume that some secured protocol used to invoke session bean and for sure if it's secured then the client must be known.

Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Exam 1Z0-810: Upgrade to Java SE 8 Programmer Study Guide and Quiz
ramesh vanka

Joined: Mar 13, 2005
Posts: 11
StatefulSession Bean:

Once client calls the Home.create() method, container creates EJBObject, Instanstiate the Session Bean and makes relation between ejbobject and sessionbean, then it will send EJBObject stub to client.

For each every client, container creates unique session bean.

So here one point to observer is, container makes the relationship between ejbobject and sessionbean.

When ever client makes call business method (Stub EJBObject), then in server side container will come into picture pick the corresponding bean to perform the business method.

Ramesh V
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
One other possibility to associate a certain proxy instance with a specific stateful EJB instance is that the proxy attaches some kind of identification token to the call that is made to the EJB. The EJB does not receive the call directly, but instead it goes to some kind of facade which, based on the identification token in the call selects the appropriate bean instance to serve the call.
Best wishes!

My free books and tutorials: http://www.slideshare.net/krizsan
I agree. Here's the link: http://aspose.com/file-tools
subject: stateless vs stateful session beans
It's not a secret anymore!