• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Stateful session bean question

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

7. try{
8. ssb.dbtAcc(30,120000.00,6.5);
10. //some code
11. }catch(java.rmi.NoSuchObjectException ex1){
12. //exception handling code here
13. }catch(java.ejb.EJBException ex2){
14. //exception 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. }

Assume ssb is a reference to a stateful session bean's remote component interface. which line will never be reached ?

A. line 12
B. line 14
C. line 16
D. line 18

Ans C.

Shouldn,t the answer be B since this is a remote component exception and hence EJBException will not be thrown ??
please advice.

Thanks
Nikita.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are correct.

C. could be thrown if its a CMT bean with dbtAcc marked as "Mandatory" and if this code isn't running under a transaction.
[ October 05, 2005: Message edited by: Peer Reynders ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMHO, C is correct.

javax.ejb.TransactionRequiredException is a system exception and all system exceptions are reported to client as RemoteException for Remote clients and EJBException for local clients.

However, I agree that javax.ejb.EJBException is also not thrown by the bean since the client seems remote.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ram Prasad:
javax.ejb.TransactionRequiredException is a system exception and all system exceptions are reported to client as RemoteException for Remote clients and EJBException for local clients.



Look closely. The question states "javax.transaction.TransactionRequiredException" not "javax.ejb.TransactionRequiredException"

javax.transaction.TransactionRequiredException ISA java.rmi.RemoteException
 
Ram Prasad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops. I meant javax.transaction.TransactionRequiredException.

After some thought (still needs to verify in code), I agree that TransactionRequiredException will be recived by the client.

If interested, this is the reasoning for my earlier post:
According to spec 18.1.1 Application exceptions (page 372), "An application exception class must not be defined as a subclass of the java.lang.RuntimeException or of the java.rmi.RemoteException." Taking this into consideration, TransactionRequiredException is a system exception (also mentioned in SCBCD Study kit). And my understanding was that remote clients will recieve RemoteException for any generated System exception. This led me into believing that TransactionRequiredException might be wrapped into a RemoteException before passing it to client.

But since TransactionRequiredException ISA RemoteException, the container simply throws it with out any wrapping.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.

In this case the relevant section in the spec was under "17.6.2.5 Mandatory":


If the client calls without a transaction context, the Container throws the javax.transaction. TransactionRequiredException exception if the client is a remote client, or the javax.ejb.TransactionRequiredLocalException if the client is a local client.



Also note it's "javax.ejb.TransactionRequiredLocalException", not "javax.ejb.TransactionRequiredException" (missed the "Local")
 
Nikita Deshmukh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So finally B is the correct answer ??

Thanks
Nikita
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic