When i call the findByPrimaryKey() method on the home object, it is seen that the constructor and setEntityContext() method of the corresponding BMP entity bean are called.
Then i use the remote object returned by the call to findByPrimaryKey() to invoke bean's business method, what happens is that the constructor and setEntityContext() is called and then ejbActivate() and ejbLoad().
My question is why is the container creating a new instance again when it's first business method is called. Isn't the container supposed to use the same instance that was created and sent to the pool while processing findByPrimaryKey(). Is this behavior conatiner dependent ? I am using jboss 3.04.
A call findByPrimaryKey() does not bind the EntityBean to
the primary key, thus does instantiate a bean, if the
container cannot find an unused bean instance in the pool.
A subsequent business call moves the EntityBean from the pool to the cache (Option A+B only) through ejbActivate(), which binds the bean to a primary key and makes the call. But, if there is no free bean in the pool, the container instantiates a new one. This has probably happened here.