• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Confused about STFL and STLS beans

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

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



 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hany Shafik,

Thanks for clearing the situation.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic