wood burning stoves*
The moose likes JBoss/WildFly and the fly likes JSP & EJB Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JSP & EJB Problem" Watch "JSP & EJB Problem" New topic
Author

JSP & EJB Problem

William Sundberg
Greenhorn

Joined: Jan 13, 2005
Posts: 2
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
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


throw RemoteException instead of that other Exception when moved to SessionBean to catch it in JSP.
William Sundberg
Greenhorn

Joined: Jan 13, 2005
Posts: 2
Thank you.

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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP & EJB Problem
 
Similar Threads
error pages
Error when page length is too long
wrong exception in JSP page
catching warnings
Error when page length is too long