users@glassfish.java.net

Re: About Stateless / Stateful Session Bean

From: <glassfish_at_javadesktop.org>
Date: Fri, 22 Aug 2008 07:38:34 PDT

Hello Kai,

Each lookup (or injection) of a stateful session bean results in a new bean identity. If you
store the reference somewhere (e.g. in the HTTP Session) and invoke it again instead
of doing a new lookup, you'll see the same state from the prior invocations.

In the stateless session bean case, it's completely up to the container which bean instance
is used for any particular invocation. Even if you invoke the same reference, there's no
guarantee which instance will be used. You could get "lucky" and have the same bean
instance used for two or more successive invocations, but that's not something your
application can count on. That's why stateless session beans should not store any
client-specific state.
[Message sent by forum member 'ksak' (ksak)]

http://forums.java.net/jive/thread.jspa?messageID=294837