This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Callbacks with System Exceptions  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 361 of the Core EJB specification it states that:

Discard instance means that the container must not invoke any business methods or container callbacks
on the instance



Now if my Stateless session bean throws a RuntimeException this would mean that the @PostConstruct callback should not get get called:



However when I invoke the add() method the @PostConstruct method is getting called every time?
 
Jarrod Felino
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is from section 12.4.2 of the EJB Core Specification.

The PreDestroy callbacks are not invoked when the bean and the interceptors are discarded as a
result of such exceptions: the lifecycle callback interceptor methods in the chain should perform any
necessary clean-up operations as the interceptor chain unwinds.



Is this because I am using JBoss and another Interceptor is handling the exception?
 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

However when I invoke the add() method the @PostConstruct method is getting called every time?



I don't see any @PostConstruct in your code.
 
Jarrod Felino
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I meant @PreDestroy
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After creating the bean, the add method is being called. Then it throws exception, so as a part of unwinding process, the @PreDestroy annotation is being called.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!