Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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

a thumb of rule of Exception

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I did a summary after reading exception of HFEJB --- all the RuntimeException (such as nullpointerexception, indexoutofarrayexception...) plus RemoteException thrown by bean, the remote client will only get RemoteException while the local client will only get EJBException. As for those exceptions thrown by container or stub, need do more detail analysis.

Is my summary right? It it is, then it will help us to remember those various exceptions
Any suggestion is welcomed.

Hai
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
U r correct when you say:
For all the RuntimeException - the remote client will only get RemoteException while the local client will only get EJBException.

But can you explain what do you mean by:
As for those exceptions thrown by container or stub, need do more detail analysis.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is correct. If you want more information on exception handling, you can also have a look at my cheat sheet which is supposed to be a more digestable view of the spec, at leats I hope so

Check it out at http://www.valoxo.ch/jr/cheatsheets.html (Exception handling)
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RemoteException must never be thrown by a bean.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Roger Chung-Wee:
RemoteException must never be thrown by a bean.



Thanks Roger, that's correct, I have overlooked that one in Hai's post.

A RemoteException can only be thrown by the container when:
1. the bean throws a system exception (a RuntimeException or a checked exception wrapped in an EJBException) AND
2. there is no caller transaction available

See my cheatsheet for more details...
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For session and entity beans, RemoteException is thrown regardless of the caller transaction.

If a business method of a CMT session bean or a CMT entity bean throws a non-application exception, the container will then always throw RemoteException to a remote client.

If the method was running with an unspecified transaction context or in the context of a transaction which the container had started immediately prior to running the method, RemoteException will be thrown.

If the bean method was running in the context of the caller�s transaction, javax.transaction.TransactionRolledbackException will be thrown. As this exception IS-A RemoteException, I am able to say that RemoteException is always thrown.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right Roger, that summarizes well (and in plain english) the lower part of my cheatsheet

The only point I forgot to clarify in my previous post (and you did it well, thank you for that ) is that TransactionRolledbackException extends from RemoteException and thus my statement should have been:

A RemoteException (or subclass thereof) is always thrown by the container when the bean throws a system exception (a RuntimeException or a checked exception wrapped in an EJBException) to remote clients.

Thanks for the clarification
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic