remm 2004/04/09 14:47:04 Modified: catalina/src/share/org/apache/catalina/startup ContextConfig.java Log: - If there's a non fatal exception (with validation), no exception will be rethrown by the digester. This will make the webapp startup fail if the XML is invalid and XML validation is enabled, even if the error isn't fatal (= the webapp would run without errors if validation was disabled). Revision Changes Path 1.44 +37 -1 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java Index: ContextConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- ContextConfig.java 25 Mar 2004 22:31:46 -0000 1.43 +++ ContextConfig.java 9 Apr 2004 21:47:04 -0000 1.44 @@ -50,6 +50,7 @@ import org.apache.catalina.session.StandardManager; import org.apache.catalina.util.StringManager; import org.apache.commons.digester.Digester; +import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXParseException; @@ -103,6 +104,12 @@ /** + * Any parse error which occurred while parsing XML descriptors. + */ + private SAXParseException parseException = null; + + + /** * The string resources for this package. */ private static final StringManager sm = @@ -252,7 +259,11 @@ ((StandardContext) context).setReplaceWelcomeFiles(true); } webDigester.push(context); + webDigester.setErrorHandler(new ContextErrorHandler()); webDigester.parse(is); + if (parseException != null) { + ok = false; + } } else { log.info("No web.xml, using defaults " + context ); } @@ -266,6 +277,7 @@ log.error(sm.getString("contextConfig.applicationParse"), e); ok = false; } finally { + parseException = null; try { if (stream != null) { stream.close(); @@ -499,7 +511,11 @@ //log.info( "Using cl: " + webDigester.getClassLoader()); webDigester.setUseContextClassLoader(false); webDigester.push(context); + webDigester.setErrorHandler(new ContextErrorHandler()); webDigester.parse(source); + if (parseException != null) { + ok = false; + } } catch (SAXParseException e) { log.error(sm.getString("contextConfig.defaultParse"), e); log.error(sm.getString("contextConfig.defaultPosition", @@ -510,6 +526,7 @@ log.error(sm.getString("contextConfig.defaultParse"), e); ok = false; } finally { + parseException = null; try { if (stream != null) { stream.close(); @@ -838,5 +855,24 @@ } } + + + private class ContextErrorHandler + implements ErrorHandler { + + public void error(SAXParseException exception) { + parseException = exception; + } + + public void fatalError(SAXParseException exception) { + parseException = exception; + } + + public void warning(SAXParseException exception) { + parseException = exception; + } + + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]