This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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

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!