This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Stateful session bean doubt  RSS feed

 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB in Action code example chapter 3 User account creation.

I invoked createAccount() which is not marked with @Remove annotation, from the client code. As a result of the JNDI lookup
a new instance of the bean is created and PostConstruct callback is invoked as shown below.

20:49:51,359 INFO [STDOUT] openConnection()
20:49:51,359 INFO [STDOUT] I am callback for PostConstruct events for this stateful session bean
20:49:51,359 INFO [STDOUT] I will be invoked after the bean is instantiated and DI are complete.

I invoked the client code again and i was surprised to see that PostConstruct callback was invoked.
Since the bean is a stateful session bean and client never invoked a buisness method with @Remove and therefore
the bean instance should continue to exists in main memory since the client invocation of the buisness method was
within say 2 seconds.
I was expecting the buisness method createAccount() to be invoked on the same session stateful bean.
20:50:06,796 INFO [STDOUT] openConnection()
20:50:06,796 INFO [STDOUT] I am callback for PostConstruct events for this stateful session bean
20:50:06,796 INFO [STDOUT] I will be invoked after the bean is instantiated and DI are complete.

I kept the client connection idle for atleast 10 minutes and PrePassivate methods were never invoked. How long does one has to wait ?
And is this time configurable from JBOSS ? [My guess is , it should be]
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I invoked the client code again


That's a new client, isn't it ? If the process ends, then your first client is gone. Not the same client, so new bean. What happens if you call createAccount() twice from the same method ?
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!