I have an Java class that will do some validating and throws an Exception if there is some problem, it work as expected if I call it direct from my JSP page and I can catch the Exception in my JSP page.
When I move the code into an Stateless session been that also throws the same Exception(this is only a wrapper and calls my Validat class as above).
I cant catch the Exception but it is handled by JBoss, so have cant I make this work? I am using JBoss 4.0.0 with JDK 1.5
Damanjit Kaur
Ranch Hand
Joined: Oct 18, 2004
Posts: 346
posted
0
When I move the code into an Stateless session been that also throws the same Exception(this is only a wrapper and calls my Validat class as above).
I cant catch the Exception but it is handled by JBoss, so have cant I make this work? I am using JBoss 4.0.0 with JDK 1.5
My ValidateException extended EJBException but if I changed it so it extended Exception it works as I wanted it.
Is this a good solution? or are there some other problem with it?
Damanjit Kaur
Ranch Hand
Joined: Oct 18, 2004
Posts: 346
posted
0
My ValidateException extended EJBException but if I changed it so it extended Exception it works as I wanted it.
Is this a good solution? or are there some other problem with it?
EJBException are subclass of RuntimeExceptions and are handled by container automatically , it results in transaction rollback. But if you use your exception class to extend Exception then the exception is sent to client but the transactions are not rolled back.
Each method begininng denotes the start of a transaction and before the method ends, the transactions are committed autmoatically in case of CMT.
So in your case, you have to decide by going thru your code if there is a neccessity of transaction rollback or not. Although throwing EJBException is most preferred.