• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

What does really occur after a system exception?

 
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ranchers,

the spec contains on the pages 375 and 376 the following informations what happens after throwing a system exceptions:

- Log the exception.
- Mark the transaction for rollback.
- Discard instance. Discard instance means that the Container must not invoke any business methods or container callbacks on the instance.

Today, I have worked with a session bean mock-exam from ejb-certificate, and there was the following question:

Given that a stateful session bean implements the SessionSynchronization interface, select the correct order in which a container calls a transactional business method that throws a system exception.

The correct answer was:
afterBegin(), business method, afterCompletion()
If a business method raises a system exception whilst in the context of transaction, afterCompletion() is called on the session bean instance with a boolean value of false to notify the instance that a rollback has occurred.


The spec wrotes, that after a system exception the instance will be discarded, and that the Container must not invoke any business methods or container callbacks on the instance. But afterCompletion() is a container-callback-method, isn't it?

Why does the Container calls afterCompletion() after a system exception? I have thought that the container will invoke NO method on the bean-instance after a system exception has occurred.

Regards,
Oliver
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the AfterComplete will be invoke when the stateful bean invoke other bean's method, and that method throw a system Exception. container will discard other bean not your stateful bean
 
reply
    Bookmark Topic Watch Topic
  • New Topic