• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checked exceptions from...'EJB' methods

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a doubt: what shall I do from an 'EJB' method if a checked exception is catched. Of the 6 bean developer's responsibilities in case of EJB exceptions, I don't remember any of these referring explicitly to EJB methods (ejbCreate, ejbActivate and so on). Following what is written in HF in case of checked exceptions catched in a business method in case of transactions, I should invoke setRollbackOnly() before catching (actually re-catching) the exception and also declare it either in the bean class and in the client's interfaces and let it propagate to the container (so that it will propagate it to the client as it is). But I remember that I shouldn't declare checked exceptions in the container callbacks methods (or I am wrong?).

It's getting late.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right. You cannot modify the throws clause of EJB methods to add application-specific exceptions except for the ejbCreate<METHOD>() methods since they are not declared in any bean interface.

Actually, application exceptions should be thrown by your business methods and not from the EJB methods since the latter are not supposed to perform operations related to your business but more life-cycle related stuff. I don't see how/why you would need to throw an application exception from an EJB method.

Does it make sense to you?
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Valentin Crettaz:

Does it make sense to you?


Yes it does, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic