Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does really occur after a system exception?

 
Oliver Rensen
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
 
chao cai
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic