This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stateless vs Stateful Session Beans" Watch "Stateless vs Stateful Session Beans" New topic
Author

Stateless vs Stateful Session Beans

Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 157

Hi Guys

I wanted to try and illustrate the difference between the two types of beans for myself, so I created a couple of classes and remote interfaces as follows:


I then exposed the call() methods through a web service and invoked each of them four times. My output (in the Glassfish log) was as follows:

INFO: Stateless bean: 1
INFO: Stateful bean: 1
INFO: Stateless bean: 2
INFO: Stateful bean: 2
INFO: Stateless bean: 3
INFO: Stateful bean: 3
INFO: Stateless bean: 4
INFO: Stateful bean: 4


I was expecting the stateful bean's counter to be incremented with each call, but I didn't expect the stateless bean to do the same - I thought that it would essentially lose track of whatever state it was in (i.e. that it would be lost after being invoked, and that the next call would get a new instance). What am I missing?

Cheers,
Riaan


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 157

Anyone?
Ragavan Natarajan
Greenhorn

Joined: Apr 09, 2012
Posts: 1
This might help you.

http://www.coderanch.com/t/312022/EJB-JEE/java/Stateless-Session-Bean-maintain-state
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 157


Thank you Ragavan, and welcome to JavaRanch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stateless vs Stateful Session Beans
 
Similar Threads
Problem in understanding session beans
EJB3 mock questions available now! (Section 2)
jsp /java i m not able to fine currect solutions
Stateless and Stateful beans....
stateless vs stateful session bean