Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ejbActivate() and ejbPassivate()

 
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
 
Ranch Hand
Posts: 262
  • 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.
 
Ranch Hand
Posts: 3389
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.

https://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: 262
  • 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
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic