Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stateless session bean instances tracking

 
blr sam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
We are using a JSP <--> (Stateless Session Beans)
EJB <--> DB to perform some simple calls. I have
called the 'beanObj.create()' in the JSP init() ie. this is done only once. In each request i am calling a method using the beanObj which retrives
data from the database.
While testing for 1000 requests I find the number
of connections to DB going upto 100. This is done
using the bean pool created by the container.
I would to know how is there are many instances of
the session bean being created as i have called
the 'beanObj.create()' in the init() ie. only
once.
Cheers
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These beans are stateless. That means that all isntances are exactly alike to the EJB container and to the client as well.
When you send create() to the EJBHome of a stateless bean you're not REALLY creating any particular instance that a client holds on to -- you're just getting an abstract reference to that type of bean for the client. If you read the spec (or Richard Monson-Haefel's excellent book) you'll find that each method you call on a stateless session bean might go to a different instance.
So, since you are testing 1000 clients it makes perfectly good sense that the container would try to handle that by filling the bean pool so that all 100 beans int he pool can handle requests simultaneously.
Kyle
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic