JBoss *is* acting according to spec and your disappointment is 
unfounded.  You're just confusing your session beans - and what your 
client stub actually represents.

If you are using *stateless* session beans (SLSB), you can have as many 
threads share that same client stub and use it concurrently.  However, 
that does NOT mean that the same instance of the SLSB is being used on 
the server side.  The server is smart enough to make sure that a 
different bean in the container is servicing each client.  A server can 
reuse SLSB's for the same or different clients, but *not at the same 
time*, and it makes sure it starts off at a fresh state before the next 
usage.  Some containers will pool instances, some will just instantiate 
new ones each call.  So basically, each time you call a SLSB, you are 
not guaranteed the same bean on the server is being used (thus the term 
"stateless").

Now, if you are using *stateful* session beans (SFSB), your one client 
stub will always point back to the same instance on the server side 
(thus you can save "state" in it - sort of like an HTTPSession).  Each 
time you invoke your stub, you are guaranteed that the same instance on 
the server is being used (until it times out or becomes invalid for 
whatever reason - in which case you'll need to get a new one).  You 
cannot share that stub with other concurrently running threads.

You should probably take a closer look at the ejb spec, specifically the 
sections on lifecycle.

Hope this helps,
David

--

LaBanca, Rick wrote:
> I did read that session beans can't be reentrant, no threads. Well I do have
> my client using the stub to one bean reference, and more than one thread use
> it.
> 
> Instead of it failing, it appears the server somehow knows, and makes the
> required number of sessions needed. So if I cause three threads to go, I'll
> get three sessions.
> 
> This is all fine, but  unless I'm wrong, I am doing something out of spec
> and really shouldn't do what I'm doing. Instead I should have one reference
> (Stub) per thread on the client.
> 
> So I'm curious. Does it work for me the way I have it because jboss is going
> beyond the spec, or am I missing something and I'm really doing things
> correctly??
> 
> I'm actually disappointed the spec won't let me write a stateless session
> bean that can deal with threads (seems pretty safe to me if I intend it).
> 
> Rick



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to