Hello,
I'd like to hear somebody's else opinion about EJBException,
I can see that it's an exception descendant of RuntimeException,
so what is the puropose of throwing it? - I sometimes see it thrown in the method signature of EJB methods or at the end of a method...is it poor coding or it has some utility ? (Sorry I cannot imagine a parallel with ordinary Java programming...I never needed to throw for example a Null Pointer Exception in my code...that's why I wonder about this question)
Regards
Francesco
-
What's the purpose of throwing an EJBException ? (3 messages)
- Posted by: fmarchioni fmarchioni
- Posted on: January 03 2001 03:49 EST
Threaded Messages (3)
- What's the purpose of throwing an EJBException ? by Samir Penkar on January 03 2001 17:51 EST
- What's the purpose of throwing an EJBException ? by Kiran Patchigolla on January 06 2001 09:41 EST
- What's the purpose of throwing an EJBException ? by timothy dennison on January 18 2001 11:34 EST
-
What's the purpose of throwing an EJBException ?[ Go to top ]
- Posted by: Samir Penkar
- Posted on: January 03 2001 17:51 EST
- in response to fmarchioni fmarchioni
Maybe this is one explanation:
An EJB exception is a System exception. When ever a System exception occurs in EJB the EJB container automatically handles it. The conatiner will:
1. Roll back the transaction
2. Log the exception to alert the system admin
3. Discard the bean instance
4. Throw a Remote Exception or one of its subtypes
To do all this you may need to explicity throw the EJB Exception.
Samir
-
What's the purpose of throwing an EJBException ?[ Go to top ]
- Posted by: Kiran Patchigolla
- Posted on: January 06 2001 09:41 EST
- in response to fmarchioni fmarchioni
You need to throw this exception explictly for informing the container that there is a system excetpion (For ex: SQLException for database unavailability etc..)
However, you do not need to declare the exception in the throws clause of the method signature, since its a sub-class of runtime exception. -
What's the purpose of throwing an EJBException ?[ Go to top ]
- Posted by: timothy dennison
- Posted on: January 18 2001 11:34 EST
- in response to Kiran Patchigolla
Actually, I believe that ejb 1.1 containers will handle any runtime exception in the same manner as EJBException (as outlined in previous message). I'm working on a project that needs to execute in weblogic 5.1 and websphere 1.0. I've coded a new exception class, EJBExceptionMigrate, that extends RuntimeException. I throw this exception in the same manner as EJBException (wrapping jndi,sql exceptions,etc.), but this allows the EJB 1.0 websphere environment to handle the exception correctly as well. This is detailed in ibm's redpiece on weblogic to websphere migration.