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.
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 ]
posted 15 years ago
Thanks, Terry. That's what I learned and thought. But now I am confused by the explanation of above question.
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.
Sindhu Murthy<br />SCJP 1.4<br />SCBCD
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Devious Experiments for a Truly Passive Greenhouse!