Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Declare to throw RemoteException

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if business interface is like this
@Rmote
public interface CreditCard implements java.rmi.Remote
methods of above interface must throws java.rmi.RemoteException

but if businees interface is like
@Rmote
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
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Deepika and Remko
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic