Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception handling

 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source - Choices from Whizlab question,


When an exception is thrown by a method invocation with CMT

- When method runs in unspecified TX context and non-AppEx is thrown, container will re-throw the Ex.
FALSE

- When method runs in unspecified TX context and non-AppEx is thrown, container will throw the EJBEx.
TRUE

- When method runs in unspecified TX context and non-AppEx is thrown, container will log the Ex.
TRUE

Doubt:
What is the difference b/w re-throw & throw (as per first two choices)?

Container will log the Ex. (Can someone please add few more words or add a related link, I missed to notice this in EJB 3 In Action)
Where container logs?

Thanks.


 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume a business method of a session bean contains the statement

throw new RuntimeException();

Then the container catches this exception, logs the exception, rolles back the transaction (if there is any) and discards the bean instance. Afterwards the container throws an EJBException, that is received by the client (in order to discover the original exception there is a method EJBException.getCausedByException()).

To re-throw an exception means, the container catches the exception, does some internal work (completing a tx, ...) and then it throws the exception that it catched before, again (this happens with application exceptions).
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.....
 
James Joshy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Rethrow means throw the same exception it caught. System Exception would go out as SystemException
Thorw here refers to wrapping the exception as throwing again , so container is not throwing back same Exception
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic