• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Final mock exam quesion on Head First EJB

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The question is:
Which of the following is performed by the container if a message-drive bean does not complete its transaction before the end of the onMessage() method?
Possible answers:
A.Log an aplication exception
B.Roll back the started transaction
C.Discard the instance of the bean
D.Throw an exception.

I have marked B and C but answer A should also be true. Is this correct?
I have understand that the container logs only system exception. Also in this case, the container cannot receive an application exception.

Regards,
Adela
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think container will throw java.lang.IllegalStateException
Anyways option C should also be selected, as container will also throw an exception.
Amol.
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please make C a D in my previous quote.
BCD
Amol.
 
Adela Popescu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amol,
Thany you for the answer. But what about answer A? I think also the container throws a system exception. I think you have right with answer D.

Regards,
Adela
 
Adela Popescu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need your help. I get the exam tomorrow morning and I want to be sure.
Can't anybody give me an answer?

Thank you,
Adela
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you are allowed to throw an exception unless it is checked (there is no client so who are we expecting to catch?)

If it is runtime in which case you don't handle it. Since a system exception causes bean to discarded. So i am not sure D is right...
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adela Popescu:

Which of the following is performed by the container if a message-drive bean does not complete its transaction before the end of the onMessage() method?
Possible answers:
A.Log an aplication exception
B.Roll back the started transaction
C.Discard the instance of the bean
D.Throw an exception.




I think B,C and D are the answers.

In this context the Client will get a RemoteException, that means the container will throw a SystemException. So the container will roll back the current transaction. Then the container will discard the instance of the bean too. any way D will be a right choice.
[ March 07, 2005: Message edited by: -Sanju Thomas- ]
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adela Popescu:
Hi,
The question is:
Which of the following is performed by the container if a message-drive bean does not complete its transaction before the end of the onMessage() method?
Possible answers:
A.Log an aplication exception
B.Roll back the started transaction
C.Discard the instance of the bean
D.Throw an exception.

I have marked B and C but answer A should also be true. Is this correct?
I have understand that the container logs only system exception. Also in this case, the container cannot receive an application exception.

Regards,
Adela



Read carefully.
1. Option A given in the book is- Application ERROR not exception.
2. Explanation is given in the answers about option D. To whom you will throw an exception? Its an MDB and it does not have clients.

Regards,
Leena
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer A B and C are correct.
read page 351 of Sun specs...

Answer A is correct because whenever there is a system exception, the Container will always log an exception to notify to the System admin that something unexpected has happened.

Answer D is incorrect because you guys are missing the basic funda of meesage driven beans. Message Driven beans do not have clients. So if the Container throws and excpetion whom will the exception be thrown...NOBODY.bcoz there s no client. So answer D is wrong.

So the correct answer is A, B and C.

Hoep that helps
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1. Option A given in the book is- Application ERROR not exception.



Leena,
The term 'error' referred to here does not mean java.lang.Error. In this case, the bean instance has left the transaction open when the onMessage() method has finished. The container detects it and logs the problem. It does not mean that the admin gets to see a stacktrace of java.lang.Error. He sees an error which would be an EJBException. My answer for this question would be A, B & C.
 
Adela Popescu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Keerthy,
EJBException is a system exception, not application exception. For me answer A is not correct. In this case the container logs a system exception

Regards,
Heidi
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Keerthi P:


Leena,
The term 'error' referred to here does not mean java.lang.Error. In this case, the bean instance has left the transaction open when the onMessage() method has finished. The container detects it and logs the problem. It does not mean that the admin gets to see a stacktrace of java.lang.Error. He sees an error which would be an EJBException. My answer for this question would be A, B & C.




I didn't refer to java.lang.Error AT ALL!

Even my answers are A and B and C. I wanted to correct the 'question' posted. I emphasised on the word ERROR by capitalising it. The reason for doing this can be found in the post by Adela right on top of this.

BTW, did anyone tell you about the Javaranch Naming Policy?

Regards,
Leena
[ March 08, 2005: Message edited by: Leena Diwan ]
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adela Popescu:
Hi Keerthy,
EJBException is a system exception, not application exception. For me answer A is not correct. In this case the container logs a system exception

Regards,
Heidi


Adela what option A means that an 'logging that application level ERROR has happened'

Please refer to the book and the question again. They have mentioned 'application error' and not 'application exception'. If they would have given an option - 'Log an application exception' then option A would be wrong.

Regards,
Leena
 
Keerthi P
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

BTW, did anyone tell you about the Javaranch Naming Policy?



Would you mind telling me what is wrong with my name ? I can change it if it is violating the naming policy. But I read I can use initials in display name.
[ March 08, 2005: Message edited by: Keerthi P ]
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i think option B and C r correct .. the option A in not correct since it says A.Log an aplication exception. The spec says the container shd simply log exce..n(s/m exce..n) thrown by the bean instance. and as evribodi knows the MDB cant throw any aplication exception

thanx
binoj
 
Keerthi P
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Read carefully.
1. Option A given in the book is - Application ERROR not exception.



Adela's post should read as:
Which of the following is performed by the container if a message-drive bean does not complete its transaction before the end of the onMessage() method?
Possible answers:
A.Log an application error
B.Roll back the started transaction
C.Discard the instance of the bean
D.Throw an exception.

As I have mentioned the above post, MDB 'always' logs any problem so that an admin can look into it offline. Even IllegalStateException, if occurred, will be logged.

So the correct answer should be A, B & C.

For more info refer Pg: 356 in the spec.
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Keerthi P:


Would you mind telling me what is wrong with my name ? I can change it if it is violating the naming policy. But I read I can use initials in display name.

[ March 08, 2005: Message edited by: Keerthi P ]



Im surprised to read that Initials are ok. But then the stmt is 'You can even use initials for the first name if you like.'

I understand that in some cultures there is no such thing as "first name and last name" - there is just one name. If you are one of these people, I would like to humbly ask you to sacrifice a piece of your culture to help me build this culture.



Here's one correction suggested earlier. :roll:
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Keerthi P:
Possible answers:
A.Log an application error



Leena: They have mentioned 'application error' and not 'application exception'.



Leena: I wanted to correct the 'question' posted. I emphasised on the word ERROR by capitalising it.



 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic