• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on Whizlabs Mock Test Question

 
Jisha Anand
Ranch Hand
Posts: 62
Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All!

The following is a question from Whizlabs mock test:

Which of the following statement is incorrect about how the exceptions are handled in EJBs?
Choose one answer.
a. When a business method of an enterprise bean throws an application exception, the container discards that instance of the bean
b. Message driven beans are not allowed to throw application exceptions to the client.
c. When a business method of an enterprise bean throws an application exception, the container always automatically rolls back the transaction.
d. The class of the exception received by the client is the same as the class of the exception when the bean throws an application exception.


It says: Choice C is the correct answer.

Ofcourse choice C is correct; which implies the statement is wrong and all other statements are correct. But I am not sure whether the choice A is correct or not. Does the container really discard an instance of a bean if it throws application exception?

Thanks in advance!
 
leonardo segala
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this question seems ill-formulated, because according to Table 14 of section 14.3.1 in core spec, after applications exceptions the container don't discard instance, but any other type of exception yes.
 
Jisha Anand
Ranch Hand
Posts: 62
Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
leonardo segala wrote:this question seems ill-formulated, because according to Table 14 of section 14.3.1 in core spec, after applications exceptions the container don't discard instance, but any other type of exception yes.


Leonardo,

I too have the same understanding. In such a case, the statement with choice A is wrong and hence the question should have both choices A, C as the answers. Am I correct?

Thanks!
 
Ross Crockett
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answers to those sound a bit dodgey.

For option B) an exception wouldn't reach a client because MDB's don't have clients. Do they mean the container?

Also even for option C) which is correct, the case exists where an application exception can be marked as @ApplicationException(rollback=false). This would not cause a rollback. In fact any exception explicitly defined as so by the bean-provider using the @ApplicationException annotation defaults to rollback=false.

Perhaps they should word this question with a code sample or something to eliminate ambiguity.
 
Jisha Anand
Ranch Hand
Posts: 62
Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even I feel the question has to re-worded and the choice has to be multiple!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic