Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning 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
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

PostConstruct/PreDestroy of a Singleton should be executed in a transaction context

 
Ranch Hand
Posts: 1759
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p.166 of Ivan's notes,


A transaction context is not available in all methods of EJBs. Examples of methods that execute in an unspecified transaction context include:
1. PostConstruct and PreDestroy methods in EJBs with container managed transactions.
2. PostConstruct and PreDestroy methods of singleton session beans.



For 1), according to the JSR-318, PostConstruct and PreDestroy lifecycle callback methods in stateful/stateless/ message driven bean are executed in unspecified transactional context.
But that does not include singleton.

For 2), according to session 4.8.3 of JSR-318, PostConstruct and PreDestroy methods of a Singleton with CMT are transactional. The transactional attributes are REQUIRED, REQUIRES_NEW or NOT_SUPPORTED.
That means these two methods are executed in
1 ) the client's transactional context;
2) or starts a new transaction while suspending the client's transaction
3) or not in any transactional context at all.

So, I think PostConstruct/PreDestroy methods of a singleton bean are not executed in an unspecified transaction context as described on p.166 of Ivan's notes.
 
Creator of Enthuware JWS+ V6
Posts: 3295
298
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So, I think PostConstruct/PreDestroy methods of a singleton bean are not executed in an unspecified transaction context as described on p.166 of Ivan's notes.


You are correct, those methods on a Singleton execute in a transaction context.
 
What's brown and sticky? ... a stick. Or a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!