Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Callbacks with System Exceptions

 
Jarrod Felino
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?
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 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: 850
  • 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