• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Doubt on Whizlabs Mock Test Question

 
Ranch Hand
Posts: 62
Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even I feel the question has to re-worded and the choice has to be multiple!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic