This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Declare to throw RemoteException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Declare to throw RemoteException" Watch "Declare to throw RemoteException" New topic

Declare to throw RemoteException

Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
This is from WhizLabs, Practice Exam 1, Q.14

Which of the following is True about business interface of an EJB 3.0 bean? (Choose two) (Choose 2)

[A] The interface must not extend javax.ejb.EJBObject or javax.ejb.EJBLocalObject interfaces.
[B] The remote business interface must implement the java.rmi.Remote interface.
[C] The throws clause of the remote business interface method must throw java.rmi.RemoteException
[D] It is not mandatory to define whether the business interface is a Remote or Local interface

The correct answers are A and D.

It is correct, but why answer [C] is wrong?

And, the explanation says:
The EJB 3.0 specification mandates that the methods of the business interface must not throw java.rmi.RemoteException.
Is this correct? I don't remember anything like this from the specs.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
In EJB2 it was true where every method in the endpoint interface must declare the java.rmi.RemoteException in its throws clause. This exception is used for reporting network problems by using the method.

With EJB3 the container will add this exception to the method so the developer doesn't have to do this in the code. This is done for making the development of EJB more easy.

Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
if business interface is like this
public interface CreditCard implements java.rmi.Remote
methods of above interface must throws java.rmi.RemoteException

but if businees interface is like
public interface CreditCard

it is not mendatory for developer add throws RemoteException to methods

but since throws RemoteException is needed, so compiler does it for developer.
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Thanks Deepika and Remko
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Declare to throw RemoteException