• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbActivate() and ejbPassivate()

 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
below is my opinion regarding the stateful session bean. Can you please give your input too and correct me if I am wrong.

In case of stateful session bean the activation and passivation of bean is done by container. The developer duty is to simply manage resources at the time of activation and passivation (for e.g. returning a database connection to pool)

Is my understanding correct? Request your opinion.

-Lave
 
Collins Mbianda
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lave !!!
I agree with what you said.

Activation and Passivation are callbacks. Those two operations are perform by the EJB container.
The container will write your statefull bean's conversational state to secondary storage,
such as a file or database.
The container informs the bean that it's about to perform passivation by calling
bean's optional PrePassivate callback method.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's perfect Collins Mbianda
 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Collins/Raghavan
I agree that ejbActivate() and ejbPassivate() are callbacks.
Why I asked this question because, I have written a stateful sessionbean, which gets passivated after some time but when I again try to hit it, it throws an exception.

I have raised question on forum also.

http://www.coderanch.com/t/163397/java-EJB-SCBCD/certification/Exception-after-ejbPassivate

Can you please have a look on that and share your opinion.

-Lave
 
Collins Mbianda
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see your example.

Passivation occur because of a limitation of resources on the container.

If you write a client to acces your bean, the instance of the statefull bean
will be pooled. It will not be passvivated since there only one client.
Try to specific code in ejbPassivate() to see what it's happening
(Put a System.out.println in ejbPassivate).

The eror message don't give any information about passivation.
It said
The EJB does not exist

I think your EJB is not deployed. Try to redeploy it and see...

Hope it help.
 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I agree Passivation occur because of a limitation of resources on the container.

My bean is correctly deployed to server. When I dtop using the instance of bean then after some time ejb gets passivated and when I try to access it again I get exception, the problem may be because the bean is destroyed because of timeout. I will try it gain.

I am already using System.out in ejbPassivate().

-Lave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic