File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes stateless session bean instances tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "stateless session bean instances tracking" Watch "stateless session bean instances tracking" New topic

stateless session bean instances tracking

blr sam

Joined: Jan 15, 2002
Posts: 7
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
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
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 Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
I agree. Here's the link:
subject: stateless session bean instances tracking
It's not a secret anymore!