Sometimes unconscious using of a simple and usual things led to unexpected consequences. And than we look on those things with misunderstanding.
Let us consider so widely known conception as handling of exception in java programming language and its impact on the enterprise application's architecture.
There are some classes that represents exception:
javax.ejb.EJBException
java.rmi.RemoteException
java.lang.RuntimeException
java.lang.Exception
java.io.IOException
java.lang.ArithmeticException
java.lang.NullPointerException
java.sql.SQLExceptionThere are some questions:
What is the relation betwen these classes?
What kind of exception can be thrown in the EJB methods?
What kind of exception will be received by EJB or WebService client?
How EJB client can receive underlying exception infofmation?
How can client of the web service retrieve proper information about exception?
Is it necessity in delivering an underlying exceptions classes to the client application?
What is best practices to handle excepion in our code?
What is best place to implemests code to write logging messages?
How can I use java.lang.Error?
For answer on first quastion enough to look into java API documentation:
ArithmeticException extends RuntimeException
EJBException extends RuntimeException
NullPointerException extends RuntimeException
SQLException extends Exception
RuntimeException extends Exception
RemoteException extends IOException
IOException extends Exception
exception extends Throwable
Inside of implementation of EJB methods there is not facility to throw some checked exception, is there? Let's consider examples: if inside of such method present some like int i = 1/0; client will receive:
java.rmi.RemoteException: EJB Exception: ;
nested exception is: java.lang.ArithmeticException: / by zero at
weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)...
If you call throw new RuntimeException("Ops!"); you get in fist lines:
java.rmi.RemoteException: EJB Exception: ;
nested exception is: java.lang.RuntimeException: Ops! at
weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)...
If you write throw new java.rmi.RemoteException(); compiler will check:
"Unhandled exception type RemoteException".
What exactly is mean "EJB Exception" in end of first line of stack trace?.. For sure we can throw EJBException inside above mentioned methods because it (EJBException) derivers its functionality from RuntimeException. What kind of exception we able to trows inside EJB methods except of RuntimeException? If exists ability to trows only RuntimeException what exactly does EJB container with these exceptions? Does it implement exception chaining?
Let us consider so widely known conception as handling of exception in java programming language and its impact on the enterprise application's architecture.
There are some classes that represents exception:
javax.ejb.EJBException
java.rmi.RemoteException
java.lang.RuntimeException
java.lang.Exception
java.io.IOException
java.lang.ArithmeticException
java.lang.NullPointerException
java.sql.SQLExceptionThere are some questions:
What is the relation betwen these classes?
What kind of exception can be thrown in the EJB methods?
What kind of exception will be received by EJB or WebService client?
How EJB client can receive underlying exception infofmation?
How can client of the web service retrieve proper information about exception?
Is it necessity in delivering an underlying exceptions classes to the client application?
What is best practices to handle excepion in our code?
What is best place to implemests code to write logging messages?
How can I use java.lang.Error?
For answer on first quastion enough to look into java API documentation:
ArithmeticException extends RuntimeException
EJBException extends RuntimeException
NullPointerException extends RuntimeException
SQLException extends Exception
RuntimeException extends Exception
RemoteException extends IOException
IOException extends Exception
exception extends Throwable
Inside of implementation of EJB methods there is not facility to throw some checked exception, is there? Let's consider examples: if inside of such method present some like int i = 1/0; client will receive:
java.rmi.RemoteException: EJB Exception: ;
nested exception is: java.lang.ArithmeticException: / by zero at
weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)...
If you call throw new RuntimeException("Ops!"); you get in fist lines:
java.rmi.RemoteException: EJB Exception: ;
nested exception is: java.lang.RuntimeException: Ops! at
weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)...
If you write throw new java.rmi.RemoteException(); compiler will check:
"Unhandled exception type RemoteException".
What exactly is mean "EJB Exception" in end of first line of stack trace?.. For sure we can throw EJBException inside above mentioned methods because it (EJBException) derivers its functionality from RuntimeException. What kind of exception we able to trows inside EJB methods except of RuntimeException? If exists ability to trows only RuntimeException what exactly does EJB container with these exceptions? Does it implement exception chaining?
No comments:
Post a Comment