• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

mock question

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given

7. try {
8. msb.calculateloan(30,12000.00,6.5);
some code here
}
11. catch(java.rmi.NoSuchObjectException ex1){
12. //exception handling code here
13. }catch(javax.ejb.EJBException ex2) {
14. //ecxeption handling code here
15. }catch (javax.transaction.TransactionRequiredException ex3){
16. //exception handling code here
17. }catch(java.rmi.RemoteException ex4) {
18. //exception handling code here
19. }
Which line will never be reached assuming msb is a reference to a stateful session beans remote component interface?
a)12
b)14
c)16
d)18
Thanks in advance
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Line 14 will never be reached. Since your client is remote...EJB Exceptions are never thrown to remote clients.EJB Exceptions propogate as RemoteExceptions to remote clients.

The only other possible SCJP Trick here was trying to catch a super class Exception first and then its sub class. But in this case that doesn't hold true. The Hierarchy is maintained here.All sub classes first and then the super class(Remote Exception)
 
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think (d) will be answer.(line 18). Because bean can never ever throw RemoteException.
 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think (d) will be answer.(line 18). Because bean can never ever throw RemoteException.



But the container can throw the RemoteException back to the client.

Example is, (from Table 15, Spec page 376) let say the method calculateloan in the above question, executes in a transaction started by Container and the method throws system exception, then container will catch this system exception, log it, rollback txn, discard instance and throw RemoteException back to client. Imran or others, correct me if this is wrong.

So, from the point of view of the Remote Client, the Remote client can actually receive the RemoteException.

I would go with answer b (line 14). The reason I think this is correct is, a bean can actually throw the EJBException (spec page 373), but the container would not pass this EJBException back to the remote client (Table 15 & 16, spec pages 375, 376, 377), so I think a remote client would never get the EJBException.
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic