This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Stateful session bean ejbRemove()

 
Lave Kulshreshtha
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which of the following cases will the container remove a session bean instance
without invoking the ejbRemove() method?
a. The bean instance throws a system exception.
b. The bean instance in a passive state times out.
c. The bean instance in the method ready state times out.
d. The bean instance calls a prohibited method of its session context.
e. The client invokes the method remove().

What all would be correct answers, books says A and B.

What about D, will this not cause bean to move to be removed without calling ejbRemove().

-Lave
[ February 28, 2008: Message edited by: Lave Kulshreshtha ]
 
Meng Tan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

"a" and "b" are definitely correct.
"c" and "e" are definitely wrong.

As for "d", an IllegalStateException will be thrown if an prohibited method of session context is called.
IllegalStateException is a RuntimeException and should cause bean to be discarded without calling @PreDestroy.
But if you consider the possibility of the bean catching the exception in a try/catch block and does not rethrow any SystemException then "d" can be wrong as an answer.
Of course, you can also argue that the same exception handling can be done for scenario of "a" which makes it wrong as an answer too.

Meng Tan
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!