You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/10/03 20:57:45 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml XmlMapper.java

craigmcc    00/10/03 11:57:45

  Modified:    catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java LocalStrings.properties
               catalina/src/share/org/apache/catalina/util/xml
                        XmlMapper.java
  Log:
  Make Catalina report parsing errors (from the XML validating parser being
  used) found in the default ($CATALINA_HOME/conf/web.xml) or application
  (WEB-INF/web.xml) deployment descriptors.  Previously, these errors were
  getting silently swallowed.
  
  NOTE:  The occurrence of such errors still does not prevent the
  application from being deployed.  This is going to require some additional
  modifications to handle all classes of application initialization errors
  in ContextConfig.
  
  Revision  Changes    Path
  1.18      +15 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ContextConfig.java	2000/10/01 03:07:05	1.17
  +++ ContextConfig.java	2000/10/03 18:57:44	1.18
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.17 2000/10/01 03:07:05 craigmcc Exp $
  - * $Revision: 1.17 $
  - * $Date: 2000/10/01 03:07:05 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.18 2000/10/03 18:57:44 craigmcc Exp $
  + * $Revision: 1.18 $
  + * $Date: 2000/10/03 18:57:44 $
    *
    * ====================================================================
    *
  @@ -103,6 +103,7 @@
   import org.apache.catalina.util.xml.XmlAction;
   import org.apache.catalina.util.xml.XmlMapper;
   import org.apache.catalina.valves.ValveBase;
  +import org.xml.sax.SAXParseException;
   
   
   /**
  @@ -110,7 +111,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.17 $ $Date: 2000/10/01 03:07:05 $
  + * @version $Revision: 1.18 $ $Date: 2000/10/03 18:57:44 $
    */
   
   public final class ContextConfig
  @@ -226,6 +227,11 @@
   	} catch (InvocationTargetException e) {
   	    log(sm.getString("contextConfig.applicationConfig"),
   		e.getTargetException());
  +        } catch (SAXParseException e) {
  +            log(sm.getString("contextConfig.applicationParse"), e);
  +            log(sm.getString("contextConfig.applicationPosition",
  +                             "" + e.getLineNumber(),
  +                             "" + e.getColumnNumber()));
   	} catch (Exception e) {
   	    log(sm.getString("contextConfig.applicationParse"), e);
   	} finally {
  @@ -611,6 +617,11 @@
   	} catch (InvocationTargetException e) {
   	    log(sm.getString("contextConfig.defaultConfig"),
   		e.getTargetException());
  +        } catch (SAXParseException e) {
  +            log(sm.getString("contextConfig.defaultParse"), e);
  +            log(sm.getString("contextConfig.defaultPosition",
  +                             "" + e.getLineNumber(),
  +                             "" + e.getColumnNumber()));
   	} catch (Exception e) {
   	    log(sm.getString("contextConfig.defaultParse"), e);
   	} finally {
  
  
  
  1.6       +2 -0      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/LocalStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalStrings.properties	2000/09/27 02:13:04	1.5
  +++ LocalStrings.properties	2000/10/03 18:57:44	1.6
  @@ -4,6 +4,7 @@
   contextConfig.applicationListener=Exception creating listener of class {0}
   contextConfig.applicationMissing=Missing application web.xml, using defaults only
   contextConfig.applicationParse=Parse error in application web.xml
  +contextConfig.applicationPosition=Occurred at line {0} column {1}
   contextConfig.applicationStart=Exception thrown by application start listener
   contextConfig.applicationStop=Exception thrown by application stop listener
   contextConfig.authenticatorConfigured=Configured an authenticator for method {0}
  @@ -22,6 +23,7 @@
   contextConfig.defaultManager=Configuring default Manager
   contextConfig.defaultMissing=Missing default web.xml, using application web.xml only
   contextConfig.defaultParse=Parse error in default web.xml
  +contextConfig.defaultPosition=Occurred at line {0} column {1}
   contextConfig.defaultResources=Configuring default Resources
   contextConfig.start=ContextConfig: Processing START
   contextConfig.stop=ContextConfig: Processing STOP
  
  
  
  1.3       +22 -1     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml/XmlMapper.java
  
  Index: XmlMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/xml/XmlMapper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XmlMapper.java	2000/09/24 02:53:01	1.2
  +++ XmlMapper.java	2000/10/03 18:57:45	1.3
  @@ -70,6 +70,13 @@
   	}
       }
   
  +
  +    public void error(SAXParseException e) throws SAXException
  +    {
  +        if (validating)
  +            fatalError(e);  // Make all parse exceptions fatal if validating
  +    }
  +
       public void startElement (String tag, AttributeList attributes)
   	throws SAXException
       {
  @@ -218,9 +225,17 @@
   	    // or throw an exception is more than one element is on the stack
      	} catch (IOException ioe) {
   	    ioe.printStackTrace();
  -	    String msg = "Can't open config file: " + xmlFile +
  +	    String msg = "Can't open config file: " +
  +                xmlFile.getAbsolutePath() +
   		" due to: " + ioe;
   	    throw new Exception(msg);
  +        } catch (SAXParseException spe) {
  +            System.out.println("PARSE error at line " +
  +                               spe.getLineNumber() + " column " +
  +                               spe.getColumnNumber() + " of " +
  +                               xmlFile.getAbsolutePath());
  +            System.out.println(spe.toString());
  +            throw spe;
   	} catch (SAXException se) {
   	    System.out.println("ERROR reading " + xmlFile);
   	    System.out.println("At " + se.getMessage());
  @@ -258,6 +273,12 @@
   	    String msg = "Can't open config file: " + xmlFile +
   		" due to: " + ioe;
   	    throw new Exception(msg);
  +        } catch (SAXParseException spe) {
  +            System.out.println("PARSE error at line " +
  +                               spe.getLineNumber() + " column " +
  +                               spe.getColumnNumber());
  +            System.out.println(spe.toString());
  +            throw spe;
   	} catch (SAXException se) {
   	    System.out.println("ERROR reading " + xmlFile);
   	    System.out.println("At " + se.getMessage());