Win a copy of Spark in Action this week in the Open Source Projects 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

TransactionRolledback Exception question

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say that a client that has a transaction context propogates that context when calling a bean method and that bean method throws a runtime execption. Does that client receive a TrasactionRolledback(Local)Exception or a RemoteException/EJBException?
It is my understanding that the container intercepts all runtime exceptions and throws either a RemoteException for remote clients or EJBException for local clients. Since TransactionRollecBackException is a runtime exception I would conclude that the container would intercept it and throw a RemoteException/EJBExcepion. In my studies I have come accross statements that would suggest that this is not the case and that the TransactionRolledback(local)Exception would be sent to the client as is. If this is the case, is this the only case where a runtime exception is passed back to the client as is, and why?
Please respond A.S.A.P. My exam is scheduled for tomorrow.
Much appreciated.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if container "wants to tell client" it has rollbacked the caller's context transcation, transcationrolledbackexception will be thrown
[ February 08, 2004: Message edited by: Micheal Lau ]
 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be RemoteException/EJBException for remote/local client.
Reason: RemoteException is super class of TransactionRolledBackException, when methods throws system/uncheck exception it will throw RemoteException not his subclass. It will come across many system exceptions which are subclass of RemoteException & EJBException.
Also remote client will never get as is system exception because it has to define RemoteException as check one for what unexcepted happen on server. As per java when you throw super class first subclass never get chance to throw him.
Hope I am making valid point otherwise someone can explain in full detail.
 
Micheal Lau
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the container finally throws EJBException/RemoteException to client,
then why we have 2 rolledback exceptions which extend from different super classes:
TranscationRolledBackLocalException (is an EJBException)
and
TranscationRolledBackException (is a RemoteException)
?
[ref hfejb p.551]
it seems the remote client can get the transcationrolledbackexception but not remoteexception
[ February 08, 2004: Message edited by: Micheal Lau ]
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RemoteException is checked exception on client side for system exception thrown from server.
In that case The client might not get the most specific exception.
HFB page 550..
 
Micheal Lau
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
p550 says the container throws EJBException doesn't mean the primary key is not duplicated --> something bad happened before checking the key is dup or not
note spec p.375 table 15
container's action:
throw javax.transcation.TranscationRolledbackException to remote client
client's view:
receives javax.transcation.TranscationRolledbackException
(not RemoteException)
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your method declares RemoteException in that case you will have to find out which exception was thrown from server.
It never says container will not throw txRolledBackException to client (it will throw but if RemoteException was declare at client side, in that case you will find out from exactly which one was thrown)
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic