This week's book giveaway is in the Spring forum.
We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line!
See this thread for details.
Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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.
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic