remm 2005/02/06 02:39:32 Modified: catalina/src/share/org/apache/catalina/core ApplicationDispatcher.java StandardContext.java StandardWrapperValve.java StandardWrapper.java Log: - Improve a little logging of servlet exceptions, which should all log the root cause. - Add a utility method in StandardWrapper. - Don't log client aborts in the request dispatcher. Revision Changes Path 1.43 +7 -21 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java Index: ApplicationDispatcher.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- ApplicationDispatcher.java 11 Jan 2005 14:01:45 -0000 1.42 +++ ApplicationDispatcher.java 6 Feb 2005 10:39:32 -0000 1.43 @@ -48,7 +48,6 @@ import org.apache.catalina.util.StringManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.tomcat.util.IntrospectionUtils; /** * Standard implementation of <code>RequestDispatcher</code> that allows a @@ -643,7 +642,7 @@ } } catch (ServletException e) { wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException", - wrapper.getName()), e); + wrapper.getName()), StandardWrapper.getRootCause(e)); servletException = e; servlet = null; } catch (Throwable e) { @@ -700,24 +699,11 @@ request.removeAttribute(Globals.JSP_FILE_ATTR); support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT, servlet, request, response); - Throwable rootCause = e; - Throwable rootCauseCheck = null; - - // Extra aggressive rootCause finding - do { - try { - rootCauseCheck = (Throwable)IntrospectionUtils.getProperty - (rootCause, "rootCause"); - if (rootCauseCheck!=null) - rootCause = rootCauseCheck; - - } catch (ClassCastException ex) { - rootCauseCheck = null; - } - } while (rootCauseCheck != null); - - wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException", - wrapper.getName()), rootCause); + Throwable rootCause = StandardWrapper.getRootCause(e); + if (!(rootCause instanceof ClientAbortException)) { + wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException", + wrapper.getName()), rootCause); + } servletException = e; } catch (RuntimeException e) { request.removeAttribute(Globals.JSP_FILE_ATTR); 1.161 +2 -2 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java Index: StandardContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- StandardContext.java 4 Feb 2005 23:39:58 -0000 1.160 +++ StandardContext.java 6 Feb 2005 10:39:32 -0000 1.161 @@ -3846,7 +3846,7 @@ } catch (ServletException e) { getServletContext().log (sm.getString("standardWrapper.loadException", - getName()), e); + getName()), StandardWrapper.getRootCause(e)); // NOTE: load errors (including a servlet that throws // UnavailableException from tht init() method) are NOT // fatal to application startup 1.33 +3 -19 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java Index: StandardWrapperValve.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- StandardWrapperValve.java 13 Jul 2004 09:43:59 -0000 1.32 +++ StandardWrapperValve.java 6 Feb 2005 10:39:32 -0000 1.33 @@ -36,7 +36,6 @@ import org.apache.catalina.valves.ValveBase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.log.SystemLogHandler; @@ -144,7 +143,7 @@ } } catch (ServletException e) { container.getLogger().error(sm.getString("standardWrapper.allocateException", - wrapper.getName()), e); + wrapper.getName()), StandardWrapper.getRootCause(e)); throwable = e; exception(request, response, e); servlet = null; @@ -249,22 +248,7 @@ // do not want to do exception(request, response, e) processing } catch (ServletException e) { request.removeAttribute(Globals.JSP_FILE_ATTR); - Throwable rootCause = e; - Throwable rootCauseCheck = null; - - // Extra aggressive rootCause finding - do { - try { - rootCauseCheck = (Throwable)IntrospectionUtils.getProperty - (rootCause, "rootCause"); - if (rootCauseCheck!=null) - rootCause = rootCauseCheck; - - } catch (ClassCastException ex) { - rootCauseCheck = null; - } - } while (rootCauseCheck != null); - + Throwable rootCause = StandardWrapper.getRootCause(e); if (!(rootCause instanceof ClientAbortException)) { container.getLogger().error(sm.getString("standardWrapper.serviceException", wrapper.getName()), rootCause); 1.57 +26 -3 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java Index: StandardWrapper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- StandardWrapper.java 22 Nov 2004 16:35:18 -0000 1.56 +++ StandardWrapper.java 6 Feb 2005 10:39:32 -0000 1.57 @@ -55,6 +55,7 @@ import org.apache.catalina.security.SecurityUtil; import org.apache.catalina.util.Enumerator; import org.apache.catalina.util.InstanceSupport; +import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.log.SystemLogHandler; import org.apache.commons.modeler.Registry; @@ -618,6 +619,30 @@ /** + * Extract the root cause from a servlet exception. + * + * @param e The servlet exception + */ + public static Throwable getRootCause(ServletException e) { + Throwable rootCause = e; + Throwable rootCauseCheck = null; + // Extra aggressive rootCause finding + do { + try { + rootCauseCheck = (Throwable)IntrospectionUtils.getProperty + (rootCause, "rootCause"); + if (rootCauseCheck!=null) + rootCause = rootCauseCheck; + + } catch (ClassCastException ex) { + rootCauseCheck = null; + } + } while (rootCauseCheck != null); + return rootCause; + } + + + /** * Refuse to add a child Container, because Wrappers are the lowest level * of the Container hierarchy. * @@ -1006,8 +1031,6 @@ } } catch (ClassNotFoundException e) { unavailable(null); - - getServletContext().log( "Error loading " + classLoader + " " + actualClass, e ); throw new ServletException (sm.getString("standardWrapper.missingClass", actualClass),
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]