I'm really confused about usage of STFL and STLS beans .
The main difference benwen them is that STFL can hold clients state and STLS can't. Thus I tried to test it with local client.
(1) Created 2 EJBs - StatelessBean and StatefullBean
(2) Deployed to Glassfish 2.1.1 AS. No any aditional configurations were made.
First time I called client and set "data" variable to 1 in STFL and STLS beans. By second call I just tried to obtain that value.
Results in fist time were as supposed:
But when calling second time I obtained following results:
There is no question about STFL - each time I obtain reference to new STFL bean thus value is 0. But why I obtained the same STLS bean
There is server.log
This is exactly how stateless bean behaves, the server uses the same instance of the stateless bean to serve multiple clients requests.
That is why it is not recommended for you to keep state in the stateless bean as your instance may end up serving a totally different client.
To recap what I have just said, any instance of stateless bean in the pool can serve any client. However statefull session bean instance are attached to the client that created it and can't be reused by another client while it is in use.