• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception handling

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.....
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic