Trying to understand exceptions and error-page

2005-02-25 Thread Wendy Smoak
With nothing configured for errors, I get a Tomcat error page:

HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it
from fulfilling this request.
exception
javax.servlet.ServletException: org.xml.sax.SAXParseException: blah, blah...
...
root cause
com.example.DAOException: org.xml.sax.SAXParseException: blah, blah...
...
Caused by: org.xml.sax.SAXParseException: blah, blah...

The code that causes it looks like this:

 try {
  ...
 } catch ( Exception ex ) {
 throw new DAOException( ex );
 }

Can someone explain why, if I put this in web.xml,

  error-page
  exception-typejavax.servlet.ServletException/exception-type
  location/WEB-INF/jsp/error/exception.jsp/location
   /error-page

it does NOT display the .jsp and instead shows the same thing as above with
all the stack traces?

I also tried configuring it for java.lang.Exception, but no luck there,
either.

I _can_ get a good error page if I configure it for the 'root cause'
DAOException, I'm just confused as to why I can't trap the ServletException.

Thank you,
Wendy Smoak
http://wiki.wendysmoak.com/cgi-bin/wiki.pl?TomcatErrorPage


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Trying to understand exceptions and error-page

2005-02-25 Thread Mike Curwen
Part of the spec says if no error-page declaration containing an
exception-type fits using the class-heirarchy match, and the exception
thrown is a ServletException or subclass thereof, the container extracts the
wrapped exception...
 
So supposing for a minute that Tomcat internals ignore any error-page that
has exception-type 'ServletException', it would then proceed to unwrap the
exception to get down to your DAOException. Which you've already proved that
you *can* catch.
 
 
I've successfully caught 'all other' exceptions (which I suppose must
include ServletExceptions), by using one error-page declaration that catches
status-code500/status-code, and then multiple exception-type's to
catch more specific exception types.

This is all on TC5.0.28 (TC4.x seemed a bit flakey on exceptions and
errorpages, but that could have been PEBKAC)



 -Original Message-
 From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
 Sent: Friday, February 25, 2005 11:27 AM
 To: Tomcat Users List
 Subject: Trying to understand exceptions and error-page
 
 
 With nothing configured for errors, I get a Tomcat error page:
 
 HTTP Status 500 -
 type Exception report
 message
 description The server encountered an internal error () that 
 prevented it from fulfilling this request. exception
 javax.servlet.ServletException: 
 org.xml.sax.SAXParseException: blah, blah... ... root cause
 com.example.DAOException: org.xml.sax.SAXParseException: 
 blah, blah... ... Caused by: org.xml.sax.SAXParseException: 
 blah, blah...
 
 The code that causes it looks like this:
 
  try {
   ...
  } catch ( Exception ex ) {
  throw new DAOException( ex );
  }
 
 Can someone explain why, if I put this in web.xml,
 
   error-page
   exception-typejavax.servlet.ServletException/exception-type
   location/WEB-INF/jsp/error/exception.jsp/location
/error-page
 
 it does NOT display the .jsp and instead shows the same thing 
 as above with all the stack traces?
 
 I also tried configuring it for java.lang.Exception, but no 
 luck there, either.
 
 I _can_ get a good error page if I configure it for the 'root 
 cause' DAOException, I'm just confused as to why I can't trap 
 the ServletException.
 
 Thank you,
 Wendy Smoak http://wiki.wendysmoak.com/cgi-bin/wiki.pl?TomcatErrorPage
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trying to understand exceptions and error-page

2005-02-25 Thread Wendy Smoak
From: Mike Curwen [EMAIL PROTECTED]
 I've successfully caught 'all other' exceptions (which I suppose must
 include ServletExceptions), by using one error-page declaration that
catches
 status-code500/status-code, and then multiple exception-type's to
 catch more specific exception types.

Thanks, that's a great idea. :) I didn't think of using both
exception-type and status-code.

Actually most of my 'regular' exceptions are configured in
struts-config.xml, but I've been unsuccessful in catching the really
horribly bad ones, and I'd rather not show stack traces if I can avoid it.

-- 
Wendy Smoak



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]