Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock question about Interfaces and Exceptions

 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In JavaBeat's site, I found this mock question around exceptions:

3)choose correct statement

1.methods of business interface may throw java.rmi.RemoteException
2.Methods of local and local home interface may throw java.rmi.RemoteException
3.Methods of web service end points interface may throw java.rmi.RemoteException
4.Methods of remote and remote home interface must not throw application exception

The answer is 3 but I think it's 1.
Am I wrong ?


For me, 1 is OK because the spec says (4.6.6) "The remote business interface is not required or expected to be a java.rmi.Remote interface. The throws clause should not include the java.rmi.RemoteException. The methods of the business interface may only throw the java.rmi.RemoteException if the interface extends java.rmi.Remote."

2 is wrong.

3 is wrong too because the spec says (4.6.11) "This means that their argument and return values must be of valid types for JAX-RPC, and their throws clauses must include the java.rmi.RemoteException. The throws clause may additionally include application exceptions."
It doesn't say "may" but "must" !

4 is wrong.

Thanks for your opinion

Beno�t
 
Sven Meys
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Methods of the "Remote" Business interface may throw a RemoteException indeed. But the question does not state whether it is remote or Local.
Local interfaces may never ever ever ever declare RemoteExceptions.
If you try doing it the container will crash by laughing at you.
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks, Sven !
 
Sven Meys
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it just seems logic to me. I'm currently learing for the EJB 2 exam but I doubt the whole logic behind local-> ejbException remote-> RemoteException has changed in ejb3.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic