Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application Exception

 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can an application exception extend from javax.ejb.EJBException class?
 
Aditya Vasudeva
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
an EJBException is a system Exception which is a subclass of RuntimeException. all EJBExceptions are system based exceptions and hence application exceptions cannot extend them. An application exception can become a system exception if you dont annotate it with @ApplicationException.
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think yes, Application Exception are those that extend exception. System exceptions are also application exception if they are annoated with @ApplicationException. System exceptions are nothing but something that extends runtime Exception. EJB Exception extends Runtime Exception. So I think you could extend EJBException & annotate with @AppException.

Can someone confirm this.

@ApplicationException
Public MyException extends EJBException {
}
 
Aditya Vasudeva
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its difficult to say this will work or not because nothing as such is mentioned in the specs...you can test it to find out...most probably it will not work.
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion it should be yes, since Application exceptions can extend RuntimeException and EJBException is also a subclass of RuntimeException.

However I want to confirm it since it is not mentioned in the specs and there was a similar question in the Enthuware mocks. But trying out won't give a clear answer since vendor implementations differ.

If it has not been mentioned in the specs then I hope it won't be asked in the exam too, because we don't have a clear answer for it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic