• 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

system exceptions

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across this question in ejbcertificate mock exam
Which of the following statements regarding message-driven bean exception handling are true?
1. Message-driven beans throw both application exceptions and system exceptions.
2. If a system exception is thrown by a method, the transaction is always rolled back by the container.
3. If a system exception is thrown by a method, the bean instance is always discarded.
4. If a system exception is thrown by a method, the client does not receive the exception.
5. If an application exception is thrown by a method, the client receives the exception.
Answer given: 3, 4.
I did not understand why option 4 is correct. I thought the client will receive a EJBException/RemoteException when a system exception occurs.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MDB does not have a client.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client knows nothing of the MDB as it only talks to the Destination. When an MDB method throws an exception, the container will always log the exception, rollback the transaction (if necessary) and destroy the MDB instance.
Should the client then send another message to the Destination, the container can pull another MDB instance from the pool to service the message.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MDB can throws System exception only.
MDB can not throws application exception and can not throws exception to client because MDB don't have any client.
MDB run in CMT
CASE 1 : Bean method runs in the context of a transaction that the Container started immediately before dispatching the method. This case happens with
Required attribute.
If
This method is throws System exception
Then
In Container
Log the exception or error.
Rollback the container-started transaction.
Discard instance.
Case 2 : Bean method runs with an unspecified transaction context.
This case happens with the NotSupported.
IF
This method is throws System Exception.
Then
In container
Log the exception or error.
Discard instance.
MDB run in BMT
Bean is message-driven bean.
If this method is throws System exception
Then
Log the exception or error.
Mark for rollback a transaction that has been started, but not yet completed, by the instance.
Discard instance.
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic