Ok, I have looked at the setup in Ivan notes and I have noticed that there is a serious mistake in his example.
There is only one
Servlet responding to all the requests, and in that Servlet the
EJB is injected once (i.e. for every client the same Stateful Session Bean). There will never be a second bean.
The way to implement this example is to add a HTTPSessionListener and do a lookup for an Stateful EJB and store in in the Session.
Add this listener to your code:
and add this to your web.xml
and do this in your Servlet:
When you run the example now, you will see what you had expected:
INFO: *** StatefulSession1Bean 1 created.
INFO: sessionCreated
INFO: *** StatefulSession1Bean 2 created.
INFO: sessionCreated
INFO: *** StatefulSession1Bean 3 created.
INFO: sessionCreated
INFO: *** StatefulSession1Bean 1 destroyed.
INFO: *** StatefulSession1Bean 3 destroyed.
INFO: *** StatefulSession1Bean 2 destroyed.
Regards,
Frits