Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbActivate and ejbPassivate never get called

 
Francesco Marchioni
author
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm studying life cycle methods in Entity Beans.
I have deployed a basic example from weblogic server(Account Entity Bean).
I can see that ejbActivate and ejbPassivate callbacks never
get called and in fact they are commented like this:


What does it mean? it's up to the container to decide if they
need to be called?
Thanks for your help
Francesco
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Francesco Marchioni:
I can see that ejbActivate and ejbPassivate callbacks never
get called


So the log shows no trace of these methods? But the log works otherwise?

Originally posted by Francesco Marchioni:
fact they are commented like this


The comments merely refer to the fact that AccountBean doesn't use these container callbacks - it doesn't mean the container won't call them.

Take a good look at the life-cycle diagram on page 185 of the EJB 2.1 specification.

Short of the possibility of a vendor dependent empty method optimization (and these methods are not empty - they've got a log statement in them) there really is only one possibility:

Your client is creating the underlying entity through one of the create methods and then later deletes the underlying entity with a call to the remove method - in the meantime the server doesn't even bother to move the bean from the "ready state" to the "pooled state" (even if the client goes away). Thats the only way the ejbActivate and ejbPassivate can be avoided.

Try reducing the pool size to a small number and then have a number of clients (greater than the pool size) access all different entities of the same entity bean type - that should force the truth to the surface.
[ October 13, 2005: Message edited by: Peer Reynders ]
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
An Account Bean should be SFSB, but just an otherwise thought....are you sure you haven't deployed it as SLSB?

Amol
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh cut off my earlier reply its not relevant.....its Entity and not SB so earlier post is void.

I'll take care now on.
Amol
 
Francesco Marchioni
author
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
thanks for your answers.
Well I have followed your advice using multiple clients
accessing the Entity Beans and sometimes I got the method
ejbActivated called. I say sometimes because it happened in
a rather randomic way....it seems more a matter of container
specific behavior....
thanks anyway for your replies.....

Francesco
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Francesco Marchioni:
it seems more a matter of container
specific behavior...


It most certainly is - well with one exception. You should always see an ejbActivate when a client accesses a pre-existing entity that no other client has loaded yet.

The container will call ejbPassivate when there are no more bean instances in the pool and it then victimizes the least recently used bean instance to save its current entity so that the bean instance can then be used for the next required entity.

Otherwise the container will only call ejbPassivate when it feels that the bean instance/entity has been idle for too long and it wants to return the instance to the pool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic