wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Final mock exam quesion on Head First EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Final mock exam quesion on Head First EJB" Watch "Final mock exam quesion on Head First EJB" New topic
Author

Final mock exam quesion on Head First EJB

Adela Popescu
Greenhorn

Joined: Oct 28, 2004
Posts: 18
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
amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162
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

Joined: Sep 05, 2003
Posts: 162
Please make C a D in my previous quote.
BCD
Amol.
Adela Popescu
Greenhorn

Joined: Oct 28, 2004
Posts: 18
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

Joined: Oct 28, 2004
Posts: 18
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
Chandra Vadlamani
Ranch Hand

Joined: Feb 15, 2003
Posts: 31
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...


Cheers<br /> <br />What's with the bottom line.<br />_ _ ____________________ _ _<br />SCJP 1.4, SCBCD 1.3, Prepping for SCEA.....
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
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- ]
Leena Diwan
Ranch Hand

Joined: Jun 18, 2001
Posts: 351
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


[SCJP2, SCWCD1.3, SCBCD]
Amol Dewhare
Greenhorn

Joined: Mar 08, 2005
Posts: 4
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
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203

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.


Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
Adela Popescu
Greenhorn

Joined: Oct 28, 2004
Posts: 18
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

Joined: Jun 18, 2001
Posts: 351
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

Joined: Jun 18, 2001
Posts: 351
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

Joined: Aug 19, 2003
Posts: 203
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 ]
Binoj Viswanathan
Ranch Hand

Joined: Feb 25, 2003
Posts: 85
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


SCJP 1.4(98%)<br />SCBCD1.3 (100%)<br />SCWCD 1.4 (93%)(w/o prep..n)
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
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

Joined: Jun 18, 2001
Posts: 351
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

Joined: Jun 18, 2001
Posts: 351
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.


 
wood burning stoves
 
subject: Final mock exam quesion on Head First EJB