File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP & EJB Problem

 
William Sundberg
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 346
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 346
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic