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 Session Bean 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 Session Bean" Watch "Stateless Session Bean" New topic

Stateless Session Bean

Edy Yu
Ranch Hand

Joined: Nov 21, 2000
Posts: 264
Here is what I understand it:
If I have a instance varible in the stateless session bean and I have two methods. The bean/container won't maintain the instance varible for me between the two method calls. But I tested the scenario in the J2ee server. It appears that the server is maintaining that for me.
Can anybody explain this for me?
Thanks in advance.

<i><br />Sun Certified Programmer for Java 2 Platform (SCJP)<br />Sun Certified Developer for Java 2 Platform (SCJD)<br />Sun Certified Web Component Developer for Java2 Platform, Enterprise Edition (SCWCD)<br />Sun Certified Business Component Developer for Java2 Platform, Enterprise Edition (SCBCD)<br />Sun Certified Enterprise Architect for J2EE (SCEA)<br />IBM Certified Enterprise Developer, WebSphere Studio V5.0<br /></i>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959

I think you're confusing "not throwing an exception" with maintaining.
You CAN define static variables - or preferably constants, providing you're willing to deal with the multi-tasking consequences. However, instance variables are tied to specific instances, and instances are created, recycled, and destroyed according to rules that don't guarantee that any two invocations - whether from the same client or another - will receive the same instance. The heavier the workload, the more likely that your application will fail unpredictably.
A *REALLY* picky appserver could check the EJB's class files and refuse to deploy anything with instance variables, but regardless, there is a reason why there's a separate type of session EJB for when you need to maintain state.
[ June 10, 2002: Message edited by: Tim Holloway ]

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: Stateless Session Bean
Similar Threads
Confused about STFL and STLS beans
Doubts in client view of a session bean
New to EJB.. Session Bean
Session Beans
Why have more than one stateless session bean?