• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejbActivate() and ejbPassivate()

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's perfect Collins Mbianda
 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I child proofed my house but they still get in. Distract them with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic