This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Will singleton be discard when system exception thrown from @PreDestroy  RSS feed

 
Ranch Hand
Posts: 1703
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Ivan's notes, p. 301, the diagram says for any system exception thrown by @PostConstruct or @PreDestroy,

1. if it is a singleton bean, the container will rollback any container started transaction. (I believe this singleton will be discarded as well)

2. If it is not a singleton bean, the container will discard the EJB instance.

But in the JSR-318, p.391, table 19, it says


Handling of exception thrown by a postconstruct or predestroy method of a stateful or stateless or singleton :
bean method condition: bean is stateful/stateless/singleton
container action: log the exception, if singleton rollback any container-started transaction, discard instance.



So, obviously, the container will discard the singleton when a system exception is thrown from @PostConstruct or @PreDestroy.
 
Creator of Enthuware JWS+ V6
Posts: 3194
276
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the Singleton will be discarded when a System Exception is thrown from the PostConstruct or PreDestroy method.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!