Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

What does really occur after a system exception?

 
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic