• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enthuware com.enthuware.ets.scbcd.v5.2.145 (Test 2 Q40)

 
Ross Crockett
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
I have some doubt over the answer to one of the drag and drop questions:

Create a valid EJB3.0 exception that is a runtime exception

<blank1>
public class <blank2> extends <blank3>

Options: @ApplicationException MyException RuntimeException RemoteException EJBException @EJBException



I put my answer as:
blank1 = @ApplicationException
blank2 = MyException
blank3 = EJBException

so the answer would look like:

@ApplicationException
public class MyException extends EJBException.

This is was not marked as being correct. Instead 'EJBException' should be swapped with 'RuntimeException'. Although this seems like the most obvious answer and is correct, EJBException extends RuntimeException, so doesn't that mean that MyException "is a" EJBException which "is a" RuntimeException?

The answer explanation gives:

An application exception that is an unchecked (i.e. Runtime) exception is defined as an application exception by annotating it with the ApplicationException metadata annotation, or denoting it in the deployment descriptor with the application-exception element.

Remember that EJBException extends RuntimeException but it is not an application exception because it is not annotated with @ApplicationException.


The second paragraph doesn't justify my answer from being incorrect does it, since I annotated MyException as an ApplicationException which through inheritance is a RuntimeException?
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB Core Spec 14.1.1
"application exception class may be defined as a subclass of the java.lang.RuntimeException"

as mentioned, must extends java.lang.RuntimeException .... not simply extends any runtime exception.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic