It could happen that you get the same instance back from the pool on consequtive calls if there is only one client calling the server (ie. no concurrency). Depends on the internal data structure of the pool.
Create more threads on the client (with different state) and you should start seeing your program breaking down.
Yes I tried with multiple clients calling the same instance. But for each client it it returning the values which is set by the set*** methods.
I think eventhough a instance variable is declared in a stateless bean it is useless coz the bean cant maintain the state.
This is possible only with statefull beans.
Or is my concept wrong.
There's no guarantee that you get the same instance back from the pool with consecutive calls when using stateless session beans. Before the invocation an instance is retrieved from the pool and after each invocation the bean instance is returned to the pool. This is why storing state that spans more than one remote method invocation doesn't work.
I also answered this in much the same way in the FAQ
forum as Juha as done here.
JBoss will only create as many instances of a bean to
meet the arrival rate of requests for the bean.
Having two, five or even ten client connections does not
necessarily mean that JBoss will create a new instance
for each one.
Your bean is very simple and each method invocation
probably only takes 10s of milliseconds. With that
throughput even ten client connections might not be
enough to get a new instance.
You need to create enough *concurrent" load so that the
arrival rate is faster than a single bean can handle.
If you can get say five requests to arrive at essentially
the same time, then more instances will be created to
handle the requests.
Hope this helps.