This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

mock question  RSS feed

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • 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
  • 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
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!