Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Application Exceptions in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Application Exceptions in EJB" Watch "Application Exceptions in EJB" New topic
Author

Application Exceptions in EJB

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

How come the specs define the javax.ejb.CreateException, javax.ejb.RemoveException, javax.ejb.FinderException,
and subclasses as Application Exceptions?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
core spec 14.1.1 says:
An application exception may be a subclass of java.lang.Exception ...
All exceptions you mentioned are direct subclasses of java.lang.Exception and are therefore application exceptions.


SCJP 5 (98%) - SCBCD 5 (98%)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

A RemoteException is also an Exception but the Spec says they are System Exceptions??
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
A RemoteException is also an Exception but the Spec says they are System Exceptions??
No that isn't true in this generality (see again 14.1.1, just read the quoted sentence to end). Runtime exceptions that are annotated with @ApplicationException (or declared correspondingly in the deployment descriptor) are application exceptions. All in all it is:

1. application exceptions are:

- checked exceptions (with exception of java.rmi.RemoteException and its subclasses)
- runtime exceptions annotated with @ApplicationException (or defined correspondingly in deployment descriptor)

2. system exceptions are: all exceptions, that aren't application exceptions; in full:

- runtime exceptions that are not declared as application exceptions
- java.rmi.RemoteException and its subclasses.


javax.ejbCreateException, javax.ejb.RemoveException and javax.ejb.FinderException are

- direct subclasses of java.lang.Exception, so they are checked exception
- distinct from java.rmi.RemoteException

Consequently they are application exceptions.
Arun Kumar Gupta
Ranch Hand

Joined: Jul 16, 2008
Posts: 33
Good explanation Ralph cleared my doubt as well


SCJP 1.4<br />SCWCD 1.5
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Originally posted by Ralph Jaus:
No that isn't true in this generality (see again 14.1.1, just read the quoted sentence to end). Runtime exceptions that are annotated with @ApplicationException (or declared correspondingly in the deployment descriptor) are application exceptions. All in all it is:

1. application exceptions are:

- checked exceptions (with exception of java.rmi.RemoteException and its subclasses)
- runtime exceptions annotated with @ApplicationException (or defined correspondingly in deployment descriptor)

2. system exceptions are: all exceptions, that aren't application exceptions; in full:

- runtime exceptions that are not declared as application exceptions
- java.rmi.RemoteException and its subclasses.


javax.ejbCreateException, javax.ejb.RemoveException and javax.ejb.FinderException are

- direct subclasses of java.lang.Exception, so they are checked exception
- distinct from java.rmi.RemoteException

Consequently they are application exceptions.


Thanks for the explanation.
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Coincidently,read the exception part in ejb3.0 in action today, and happend to fine such a good read.Thanks!


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Which chapter is that which talks about Exceptions in the EJB 3.0 in Action book?
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Joth,
I strongly recommend you the spec for exceptions, transaction, security, and overview (responsibilities of roles).
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Originally posted by Chaminda Amarasinghe:
Joth,
I strongly recommend you the spec for exceptions, transaction, security, and overview (responsibilities of roles).


I was considering to do that. Thanks!
 
jQuery in Action, 2nd edition
 
subject: Application Exceptions in EJB
 
Similar Threads
Difference between Error and Exception
writing from a jar
Can't callbacks throw checked exceptions?
Application Exceptions in Bean
How to supress Runtime Exceptions