• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Throw EJBException for Local only or for both Local and Remote?

 
X. Li
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question regarding 'throw EJBException' from a business method.
In P.543 of HF EJB, Bean Provider's responsibilitys (3), it says: " If your business logic catches an exception the client is not expecting, wrap it and rethrow it as an EJBException". My question is if Bean should throw EJBException for both Remote and Local client, or for Local client only? That is, if we should throw RemoteException for Remote client, and throw EJBException for Local client?

I met a question and was confused here:SCBCD Practice Test . When explaining the answer, it says: "The difficult thing to do here is to decorticate the information contained in the question statement. First, we know that the bean throws a javax.ejb.EJBException, so we know we are dealing with a local client. Therefore, we can eliminate choices C, D and E right away."
It sounds like if bean throws EJBException from a business method, it must have a local client.

Can anyone clarify it?

Thanks,

X. Li
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could be wrong, but I believe that the only difference is how the container handles the EJBException that is rethrown by the bean. If the client is local, the container just passes that along. If the client is remote, the container wraps the EJBException in a RemoteException. What does everyone else think?
[ November 25, 2004: Message edited by: Terry McKee ]
 
X. Li
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Terry. That's what I learned and thought. But now I am confused by the explanation of above question.

X. Li
 
sandeep vaid
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the question is not giving correct senario as the expalination in anwer is given as it is duty of the container to decide which Exception to throw depending on client i.e. Remote or local.

Thanks!!
sandy
[ November 29, 2004: Message edited by: sandeep vaid ]
 
Jimsecond Huang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this question just want to test your knowledge about what kind of exception will cause transaction roll back. I will choose choice e.
 
M Murthy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think the correct answer is choice b and e. The answer would have been only choice b if in the question they had specified that the client is local. Similarly the choice is only e if they had specified in the question that the client is remote.
Since the question does not say whether the client is local or remote we cannot say for sure if it is b or e. Note that any bean business method never throws a RemoteException. Only the container throws a RemoteException to a remote client, else it passes the EJBException to the client as is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic