• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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

 
Ranch Hand
Posts: 1738
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: 3287
296
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!