remm        2003/03/12 13:19:26

  Modified:    catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java
  Log:
  - Also use the CL to load the default config.
  
  Revision  Changes    Path
  1.21      +19 -18    
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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ContextConfig.java        12 Mar 2003 07:12:28 -0000      1.20
  +++ ContextConfig.java        12 Mar 2003 21:19:26 -0000      1.21
  @@ -653,20 +653,24 @@
           }
   
           InputStream stream = null;
  -        //if( ! file.exists() ) {
  -            // try using resource ??
  +        InputSource source = null;
   
  -        //}
           try {
  -            // XXX why all this instead of exists() ?
  -            stream = new FileInputStream(file.getCanonicalPath());
  -            stream.close();
  -            stream = null;
  -        } catch (FileNotFoundException e) {
  -            log.error(sm.getString("contextConfig.defaultMissing") + " " + file);
  -            return;
  -        } catch (IOException e) {
  -            log.error(sm.getString("contextConfig.defaultMissing") + " " + file , 
e);
  +            if ( ! file.exists() ) {
  +                // Use getResource and getResourceAsStream
  +                stream = getClass().getClassLoader()
  +                    .getResourceAsStream(defaultWebXml);
  +                source = new InputSource
  +                    (getClass().getClassLoader()
  +                     .getResource(defaultWebXml).toString());
  +            } else {
  +                source =
  +                    new InputSource("file://" + file.getAbsolutePath());
  +                stream = new FileInputStream(file);
  +            }
  +        } catch (Exception e) {
  +            log.error(sm.getString("contextConfig.defaultMissing") 
  +                      + " " + defaultWebXml + " " + file , e);
               return;
           }
   
  @@ -677,10 +681,7 @@
           // Process the default web.xml file
           synchronized (webDigester) {
               try {
  -                InputSource is =
  -                    new InputSource("file://" + file.getAbsolutePath());
  -                stream = new FileInputStream(file);
  -                is.setByteStream(stream);
  +                source.setByteStream(stream);
                   webDigester.setDebug(getDebug());
                   
                   if (context instanceof StandardContext)
  @@ -690,7 +691,7 @@
                   //log.info( "Using cl: " + webDigester.getClassLoader());
                   webDigester.setUseContextClassLoader(false);
                   webDigester.push(context);
  -                webDigester.parse(is);
  +                webDigester.parse(source);
               } catch (SAXParseException e) {
                   log.error(sm.getString("contextConfig.defaultParse"), e);
                   log.error(sm.getString("contextConfig.defaultPosition",
  
  
  

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

Reply via email to