5 Replies Latest reply on Aug 14, 2002 8:59 PM by John-Luc Bakker

    Stateful Session Bean dilema

    John-Luc Bakker Newbie

      Hi all,

      I an maintaining somebody's piece of software/prototype that is supposed to process multiple HTTP requests coming from multiple clients. It is designed like this: there is one servlet that gets a reference to a SFSB upon the first/initial request of a client and stores that SFSB in a Map. Subsequent requests of the same client can be identified by the key. The servlet retrieves the SFSB using the key in the URL upon a 'subsequent' request.

      So the SFSB is designed to be stateful even between subsequent requests.

      Now, I put this to test and fired two initial requests at the servlet and two SFSBs were created. Yet, soon concurrent access occured and it failed with a dreaded transaction context violation exception. The solution is to synchronize access to the SFSB.

      In my mind, this is not concurrent access as two beans were created via the Home interface. Synchronization is not the answer as it essentially means every request will have to wait for the other request to complete. Should I make SFSB stateless? Why? I still think that I have two SFSB instances thus two requests should be handled in parallel.

      Regards,

      John-Luc