~ubuntu-branches/ubuntu/trusty/tomcat6/trusty

« back to all changes in this revision

Viewing changes to java/org/apache/catalina/startup/ContextConfig.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-02-17 00:02:00 UTC
  • mfrom: (1.2.10)
  • Revision ID: package-import@ubuntu.com-20140217000200-qs6ki7bhqnfhkas7
Tags: 6.0.39-1
* Team upload.
* New upstream release.
  - Refreshed the patches
* Standards-Version updated to 3.9.5 (no changes)
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball
* Use canonical URL for the Vcs-Git field

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
6
 * (the "License"); you may not use this file except in compliance with
7
7
 * the License.  You may obtain a copy of the License at
8
 
 * 
 
8
 *
9
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 * 
 
10
 *
11
11
 * Unless required by applicable law or agreed to in writing, software
12
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
 * See the License for the specific language governing permissions and
15
15
 * limitations under the License.
16
16
 */
17
 
 
18
 
 
19
17
package org.apache.catalina.startup;
20
18
 
21
 
 
22
19
import java.io.File;
23
20
import java.io.FileInputStream;
24
21
import java.io.FileNotFoundException;
52
49
import org.apache.catalina.deploy.LoginConfig;
53
50
import org.apache.catalina.deploy.SecurityConstraint;
54
51
import org.apache.catalina.util.StringManager;
 
52
import org.apache.juli.logging.Log;
 
53
import org.apache.juli.logging.LogFactory;
 
54
import org.apache.tomcat.util.descriptor.DigesterFactory;
 
55
import org.apache.tomcat.util.descriptor.XmlErrorHandler;
55
56
import org.apache.tomcat.util.digester.Digester;
56
57
import org.apache.tomcat.util.digester.RuleSet;
57
58
import org.xml.sax.ErrorHandler;
64
65
 *
65
66
 * @author Craig R. McClanahan
66
67
 * @author Jean-Francois Arcand
67
 
 * @version $Id: ContextConfig.java 1228244 2012-01-06 16:09:08Z kkolinko $
 
68
 * @version $Id: ContextConfig.java 1558828 2014-01-16 15:12:59Z markt $
68
69
 */
69
 
 
70
 
public class ContextConfig
71
 
    implements LifecycleListener {
72
 
 
73
 
    protected static org.apache.juli.logging.Log log=
74
 
        org.apache.juli.logging.LogFactory.getLog( ContextConfig.class );
 
70
public class ContextConfig implements LifecycleListener {
 
71
 
 
72
    protected static Log log = LogFactory.getLog( ContextConfig.class );
 
73
 
 
74
    /**
 
75
     * The string resources for this package.
 
76
     */
 
77
    protected static final StringManager sm =
 
78
        StringManager.getManager(Constants.Package);
 
79
 
75
80
 
76
81
    // ----------------------------------------------------- Instance Variables
77
82
 
100
105
     * The default web application's context file location.
101
106
     */
102
107
    protected String defaultContextXml = null;
103
 
    
104
 
    
 
108
 
 
109
 
105
110
    /**
106
111
     * The default web application's deployment descriptor location.
107
112
     */
108
113
    protected String defaultWebXml = null;
109
 
    
110
 
    
 
114
 
 
115
 
111
116
    /**
112
117
     * Track any fatal errors during startup configuration processing.
113
118
     */
116
121
 
117
122
    /**
118
123
     * Any parse error which occurred while parsing XML descriptors.
 
124
     * @deprecated Unused. Will be removed in Tomcat 7.0.x.
119
125
     */
 
126
    @Deprecated
120
127
    protected SAXParseException parseException = null;
121
128
 
122
 
    
 
129
 
123
130
    /**
124
131
     * Original docBase.
125
132
     */
126
133
    protected String originalDocBase = null;
127
 
    
 
134
 
128
135
 
129
136
    /**
130
 
     * The string resources for this package.
 
137
     * Anti-locking docBase. It is a path to a copy of the web application
 
138
     * in the java.io.tmpdir directory. This path is always an absolute one.
131
139
     */
132
 
    protected static final StringManager sm =
133
 
        StringManager.getManager(Constants.Package);
 
140
    private File antiLockingDocBase = null;
134
141
 
135
142
 
136
143
    /**
138
145
     * context files.
139
146
     */
140
147
    protected static Digester contextDigester = null;
141
 
    
142
 
    
 
148
 
 
149
 
143
150
    /**
144
151
     * The <code>Digester</code> we will use to process web application
145
152
     * deployment descriptor files.
146
153
     */
147
 
    protected static Digester webDigester = null;
148
 
    
149
 
    
150
 
    /**
151
 
     * The <code>Rule</code> used to parse the web.xml
152
 
     */
153
 
    protected static WebRuleSet webRuleSet = new WebRuleSet();
 
154
    protected Digester webDigester = null;
 
155
    protected WebRuleSet webRuleSet = null;
154
156
 
155
157
    /**
156
158
     * Attribute value used to turn on/off XML validation
 
159
     * @deprecated Unused. Will be removed in Tomcat 7.0.x.
157
160
     */
158
 
     protected static boolean xmlValidation = false;
 
161
    @Deprecated
 
162
    protected static boolean xmlValidation = false;
159
163
 
160
164
 
161
165
    /**
162
166
     * Attribute value used to turn on/off XML namespace awarenes.
 
167
     * @deprecated Unused. Will be removed in Tomcat 7.0.x.
163
168
     */
 
169
    @Deprecated
164
170
    protected static boolean xmlNamespaceAware = false;
165
171
 
166
 
    
 
172
 
167
173
    /**
168
174
     * Deployment count.
169
175
     */
170
176
    protected static long deploymentCount = 0L;
171
 
    
172
 
    
 
177
 
 
178
 
173
179
    protected static final LoginConfig DUMMY_LOGIN_CONFIG =
174
180
                                new LoginConfig("NONE", null, null, null);
175
181
 
176
182
 
177
183
    // ------------------------------------------------------------- Properties
178
 
 
179
 
 
180
184
    /**
181
185
     * Return the location of the default deployment descriptor
182
186
     */
264
268
        } else if (event.getType().equals(StandardContext.AFTER_START_EVENT)) {
265
269
            // Restore docBase for management tools
266
270
            if (originalDocBase != null) {
267
 
                String docBase = context.getDocBase();
268
271
                context.setDocBase(originalDocBase);
269
 
                originalDocBase = docBase;
270
272
            }
271
273
        } else if (event.getType().equals(Lifecycle.STOP_EVENT)) {
272
 
            if (originalDocBase != null) {
273
 
                String docBase = context.getDocBase();
274
 
                context.setDocBase(originalDocBase);
275
 
                originalDocBase = docBase;
276
 
            }
277
274
            stop();
278
275
        } else if (event.getType().equals(Lifecycle.INIT_EVENT)) {
279
276
            init();
291
288
     * Process the application classes annotations, if it exists.
292
289
     */
293
290
    protected void applicationAnnotationsConfig() {
294
 
        
 
291
 
295
292
        long t1=System.currentTimeMillis();
296
 
        
 
293
 
297
294
        WebAnnotationSet.loadApplicationAnnotations(context);
298
 
        
 
295
 
299
296
        long t2=System.currentTimeMillis();
300
297
        if (context instanceof StandardContext) {
301
298
            ((StandardContext) context).setStartupTime(t2-t1+
336
333
            }
337
334
            return;
338
335
        }
339
 
        
 
336
 
340
337
        long t1=System.currentTimeMillis();
341
338
 
342
339
        URL url=null;
355
352
                    if (context instanceof StandardContext) {
356
353
                        ((StandardContext) context).setReplaceWelcomeFiles(true);
357
354
                    }
 
355
 
 
356
                    XmlErrorHandler handler = new XmlErrorHandler();
 
357
 
358
358
                    webDigester.push(context);
359
 
                    webDigester.setErrorHandler(new ContextErrorHandler());
 
359
                    webDigester.setErrorHandler(handler);
360
360
 
361
361
                    if(log.isDebugEnabled()) {
362
362
                        log.debug("Parsing application web.xml file at " + url.toExternalForm());
364
364
 
365
365
                    webDigester.parse(is);
366
366
 
367
 
                    if (parseException != null) {
 
367
                    if (handler.getWarnings().size() > 0 ||
 
368
                            handler.getErrors().size() > 0) {
368
369
                        ok = false;
 
370
                        handler.logFindings(log, is.getSystemId());
369
371
                    }
370
372
                } else {
371
373
                    log.info("No web.xml, using defaults " + context );
381
383
                ok = false;
382
384
            } finally {
383
385
                webDigester.reset();
384
 
                parseException = null;
385
386
                try {
386
387
                    if (stream != null) {
387
388
                        stream.close();
514
515
 
515
516
 
516
517
    /**
517
 
     * Create (if necessary) and return a Digester configured to process the
518
 
     * web application deployment descriptor (web.xml).
519
 
     */
520
 
    protected static Digester createWebDigester() {
521
 
        Digester webDigester =
522
 
            createWebXmlDigester(xmlNamespaceAware, xmlValidation);
523
 
        return webDigester;
524
 
    }
525
 
 
526
 
 
527
 
    /**
528
 
     * Create (if necessary) and return a Digester configured to process the
529
 
     * web application deployment descriptor (web.xml).
530
 
     */
531
 
    public static Digester createWebXmlDigester(boolean namespaceAware,
532
 
                                                boolean validation) {
533
 
        
534
 
        Digester webDigester =  DigesterFactory.newDigester(xmlValidation,
535
 
                                                            xmlNamespaceAware,
536
 
                                                            webRuleSet);
537
 
        return webDigester;
538
 
    }
539
 
 
540
 
    
 
518
     * Create and return a Digester configured to process the
 
519
     * web application deployment descriptor (web.xml).
 
520
     */
 
521
    protected void createWebXmlDigester(boolean namespaceAware,
 
522
            boolean validation) {
 
523
 
 
524
        boolean blockExternal = context.getXmlBlockExternal();
 
525
 
 
526
        webRuleSet = new WebRuleSet();
 
527
        webDigester = DigesterFactory.newDigester(validation,
 
528
                namespaceAware, webRuleSet, blockExternal);
 
529
        webDigester.getParser();
 
530
    }
 
531
 
 
532
 
541
533
    /**
542
534
     * Create (if necessary) and return a Digester configured to process the
543
535
     * context configuration descriptor for an application.
594
586
                    source = new InputSource
595
587
                            (getClass().getClassLoader()
596
588
                            .getResource(defaultWebXml).toString());
597
 
                } 
598
 
                if( stream== null ) { 
 
589
                }
 
590
                if( stream== null ) {
599
591
                    // maybe embedded
600
592
                    stream = getClass().getClassLoader()
601
593
                        .getResourceAsStream("web-embed.xml");
603
595
                        source = new InputSource
604
596
                        (getClass().getClassLoader()
605
597
                                .getResource("web-embed.xml").toString());
606
 
                    }                                         
 
598
                    }
607
599
                }
608
 
                
 
600
 
609
601
                if( stream== null ) {
610
602
                    log.info("No default web.xml");
611
603
                }
616
608
                context.addWatchedResource(file.getAbsolutePath());
617
609
            }
618
610
        } catch (Exception e) {
619
 
            log.error(sm.getString("contextConfig.defaultMissing") 
 
611
            log.error(sm.getString("contextConfig.defaultMissing")
620
612
                      + " " + defaultWebXml + " " + file , e);
621
613
        }
622
614
 
634
626
 
635
627
        String resourceName = getHostConfigPath(Constants.HostWebXml);
636
628
        file = new File(getConfigBase(), resourceName);
637
 
        
 
629
 
638
630
        try {
639
631
            if ( ! file.exists() ) {
640
632
                // Use getResource and getResourceAsStream
651
643
                stream = new FileInputStream(file);
652
644
            }
653
645
        } catch (Exception e) {
654
 
            log.error(sm.getString("contextConfig.defaultMissing") 
 
646
            log.error(sm.getString("contextConfig.defaultMissing")
655
647
                      + " " + resourceName + " " + file , e);
656
648
        }
657
649
 
666
658
    /**
667
659
     * Process a default web.xml.
668
660
     */
669
 
    protected void processDefaultWebConfig(Digester digester, InputStream stream, 
 
661
    protected void processDefaultWebConfig(Digester digester, InputStream stream,
670
662
            InputSource source) {
671
663
 
672
664
        if (log.isDebugEnabled())
673
 
            log.debug("Processing context [" + context.getName() 
 
665
            log.debug("Processing context [" + context.getName()
674
666
                    + "] web configuration resource " + source.getSystemId());
675
667
 
676
668
        // Process the default web.xml file
677
669
        synchronized (digester) {
678
670
            try {
679
671
                source.setByteStream(stream);
680
 
                
 
672
 
681
673
                if (context instanceof StandardContext)
682
674
                    ((StandardContext) context).setReplaceWelcomeFiles(true);
683
675
                digester.setClassLoader(this.getClass().getClassLoader());
684
676
                digester.setUseContextClassLoader(false);
 
677
                XmlErrorHandler handler = new XmlErrorHandler();
685
678
                digester.push(context);
686
 
                digester.setErrorHandler(new ContextErrorHandler());
 
679
                digester.setErrorHandler(handler);
687
680
                digester.parse(source);
688
 
                if (parseException != null) {
 
681
                if (handler.getWarnings().size() > 0 ||
 
682
                        handler.getErrors().size() > 0) {
689
683
                    ok = false;
 
684
                    handler.logFindings(log, source.getSystemId());
690
685
                }
691
686
            } catch (SAXParseException e) {
692
687
                log.error(sm.getString("contextConfig.defaultParse"), e);
699
694
                ok = false;
700
695
            } finally {
701
696
                digester.reset();
702
 
                parseException = null;
703
697
                try {
704
698
                    if (stream != null) {
705
699
                        stream.close();
716
710
     * Process the default configuration file, if it exists.
717
711
     */
718
712
    protected void contextConfig() {
719
 
        
 
713
 
720
714
        // Open the default context.xml file, if it exists
721
715
        if( defaultContextXml==null && context instanceof StandardContext ) {
722
716
            defaultContextXml = ((StandardContext)context).getDefaultContextXml();
734
728
        }
735
729
        if (context.getConfigFile() != null)
736
730
            processContextConfig(new File(context.getConfigFile()), null);
737
 
        
 
731
 
738
732
    }
739
733
 
740
 
    
 
734
 
741
735
    /**
742
736
     * Process a context.xml.
743
737
     */
744
738
    protected void processContextConfig(File baseDir, String resourceName) {
745
 
        
 
739
 
746
740
        if (log.isDebugEnabled())
747
 
            log.debug("Processing context [" + context.getName() 
 
741
            log.debug("Processing context [" + context.getName()
748
742
                    + "] configuration file " + baseDir + " " + resourceName);
749
743
 
750
744
        InputSource source = null;
754
748
        if (resourceName != null) {
755
749
            file = new File(baseDir, resourceName);
756
750
        }
757
 
        
 
751
 
758
752
        try {
759
753
            if ( !file.exists() ) {
760
754
                if (resourceName != null) {
776
770
                context.addWatchedResource(file.getAbsolutePath());
777
771
            }
778
772
        } catch (Exception e) {
779
 
            log.error(sm.getString("contextConfig.contextMissing",  
 
773
            log.error(sm.getString("contextConfig.contextMissing",
780
774
                      resourceName + " " + file) , e);
781
775
        }
782
 
        
 
776
 
783
777
        if (source == null)
784
778
            return;
785
779
        synchronized (contextDigester) {
787
781
                source.setByteStream(stream);
788
782
                contextDigester.setClassLoader(this.getClass().getClassLoader());
789
783
                contextDigester.setUseContextClassLoader(false);
 
784
                XmlErrorHandler handler = new XmlErrorHandler();
790
785
                contextDigester.push(context.getParent());
791
786
                contextDigester.push(context);
792
 
                contextDigester.setErrorHandler(new ContextErrorHandler());
 
787
                contextDigester.setErrorHandler(handler);
793
788
                contextDigester.parse(source);
794
 
                if (parseException != null) {
 
789
                if (handler.getWarnings().size() > 0 ||
 
790
                        handler.getErrors().size() > 0) {
795
791
                    ok = false;
 
792
                    handler.logFindings(log, source.getSystemId());
796
793
                }
797
794
                if (log.isDebugEnabled())
798
 
                    log.debug("Successfully processed context [" + context.getName() 
 
795
                    log.debug("Successfully processed context [" + context.getName()
799
796
                            + "] configuration file " + baseDir + " " + resourceName);
800
797
            } catch (SAXParseException e) {
801
798
                log.error(sm.getString("contextConfig.contextParse",
810
807
                ok = false;
811
808
            } finally {
812
809
                contextDigester.reset();
813
 
                parseException = null;
814
810
                try {
815
811
                    if (stream != null) {
816
812
                        stream.close();
822
818
        }
823
819
    }
824
820
 
825
 
    
 
821
 
826
822
    /**
827
823
     * Adjust docBase.
828
824
     */
829
825
    protected void fixDocBase()
830
826
        throws IOException {
831
 
        
 
827
 
832
828
        Host host = (Host) context.getParent();
833
829
        String appBase = host.getAppBase();
834
830
 
835
831
        boolean unpackWARs = true;
836
832
        if (host instanceof StandardHost) {
837
 
            unpackWARs = ((StandardHost) host).isUnpackWARs() 
 
833
            unpackWARs = ((StandardHost) host).isUnpackWARs()
838
834
                && ((StandardContext) context).getUnpackWAR();
839
835
        }
840
836
 
842
838
        if (canonicalAppBase.isAbsolute()) {
843
839
            canonicalAppBase = canonicalAppBase.getCanonicalFile();
844
840
        } else {
845
 
            canonicalAppBase = 
 
841
            canonicalAppBase =
846
842
                new File(System.getProperty("catalina.base"), appBase)
847
843
                .getCanonicalFile();
848
844
        }
873
869
        }
874
870
        file = new File(docBase);
875
871
        String origDocBase = docBase;
876
 
        
 
872
 
877
873
        String pathName = context.getPath();
878
874
        if (pathName.equals("")) {
879
875
            pathName = "ROOT";
929
925
        context.setDocBase(docBase);
930
926
 
931
927
    }
932
 
    
933
 
    
934
 
    protected void antiLocking()
935
 
        throws IOException {
936
 
 
937
 
        if ((context instanceof StandardContext) 
 
928
 
 
929
 
 
930
    protected void antiLocking() throws IOException {
 
931
 
 
932
        if ((context instanceof StandardContext)
938
933
            && ((StandardContext) context).getAntiResourceLocking()) {
939
 
            
 
934
 
940
935
            Host host = (Host) context.getParent();
941
936
            String appBase = host.getAppBase();
942
937
            String docBase = context.getDocBase();
943
938
            if (docBase == null)
944
939
                return;
945
 
            if (originalDocBase == null) {
946
 
                originalDocBase = docBase;
947
 
            } else {
948
 
                docBase = originalDocBase;
949
 
            }
 
940
            originalDocBase = docBase;
 
941
 
950
942
            File docBaseFile = new File(docBase);
951
943
            if (!docBaseFile.isAbsolute()) {
952
944
                File file = new File(appBase);
955
947
                }
956
948
                docBaseFile = new File(file, docBase);
957
949
            }
958
 
            
 
950
 
959
951
            String path = context.getPath();
960
952
            if (path == null) {
961
953
                return;
970
962
                }
971
963
            }
972
964
 
973
 
            File file = null;
974
965
            if (originalDocBase.toLowerCase().endsWith(".war")) {
975
 
                file = new File(System.getProperty("java.io.tmpdir"),
 
966
                antiLockingDocBase = new File(
 
967
                        System.getProperty("java.io.tmpdir"),
976
968
                        deploymentCount++ + "-" + docBase + ".war");
977
969
            } else {
978
 
                file = new File(System.getProperty("java.io.tmpdir"), 
 
970
                antiLockingDocBase = new File(
 
971
                        System.getProperty("java.io.tmpdir"),
979
972
                        deploymentCount++ + "-" + docBase);
980
973
            }
981
 
            
 
974
            antiLockingDocBase = antiLockingDocBase.getAbsoluteFile();
 
975
 
982
976
            if (log.isDebugEnabled())
983
 
                log.debug("Anti locking context[" + context.getPath() 
984
 
                        + "] setting docBase to " + file);
985
 
            
 
977
                log.debug("Anti locking context[" + context.getPath()
 
978
                        + "] setting docBase to " +
 
979
                        antiLockingDocBase.getPath());
 
980
 
986
981
            // Cleanup just in case an old deployment is lying around
987
 
            ExpandWar.delete(file);
988
 
            if (ExpandWar.copy(docBaseFile, file)) {
989
 
                context.setDocBase(file.getAbsolutePath());
 
982
            ExpandWar.delete(antiLockingDocBase);
 
983
            if (ExpandWar.copy(docBaseFile, antiLockingDocBase)) {
 
984
                context.setDocBase(antiLockingDocBase.getPath());
990
985
            }
991
 
            
992
986
        }
993
 
        
994
987
    }
995
 
    
 
988
 
996
989
 
997
990
    /**
998
991
     * Process a "init" event for this Context.
1000
993
    protected void init() {
1001
994
        // Called from StandardContext.init()
1002
995
 
1003
 
        if (webDigester == null){
1004
 
            webDigester = createWebDigester();
1005
 
            webDigester.getParser();
1006
 
        }
1007
 
        
1008
996
        if (contextDigester == null){
1009
997
            contextDigester = createContextDigester();
1010
998
            contextDigester.getParser();
1014
1002
            log.debug(sm.getString("contextConfig.init"));
1015
1003
        context.setConfigured(false);
1016
1004
        ok = true;
1017
 
        
 
1005
 
1018
1006
        contextConfig();
1019
 
        
 
1007
 
1020
1008
        try {
1021
1009
            fixDocBase();
1022
1010
        } catch (IOException e) {
1023
1011
            log.error(sm.getString(
1024
1012
                    "contextConfig.fixDocBase", context.getPath()), e);
1025
1013
        }
1026
 
        
 
1014
 
 
1015
        createWebXmlDigester(context.getXmlNamespaceAware(),
 
1016
                context.getXmlValidation());
1027
1017
    }
1028
 
    
1029
 
    
 
1018
 
 
1019
 
1030
1020
    /**
1031
1021
     * Process a "before start" event for this Context.
1032
1022
     */
1033
1023
    protected synchronized void beforeStart() {
1034
 
        
 
1024
 
1035
1025
        try {
1036
1026
            antiLocking();
1037
1027
        } catch (IOException e) {
1038
1028
            log.error(sm.getString("contextConfig.antiLocking"), e);
1039
1029
        }
1040
 
        
 
1030
 
1041
1031
    }
1042
 
    
1043
 
    
 
1032
 
 
1033
 
1044
1034
    /**
1045
1035
     * Process a "start" event for this Context.
1046
1036
     */
1050
1040
        if (log.isDebugEnabled())
1051
1041
            log.debug(sm.getString("contextConfig.start"));
1052
1042
 
1053
 
        // Set properties based on DefaultContext
1054
 
        Container container = context.getParent();
1055
 
        if( !context.getOverride() ) {
1056
 
            if( container instanceof Host ) {
1057
 
                // Reset the value only if the attribute wasn't
1058
 
                // set on the context.
1059
 
                xmlValidation = context.getXmlValidation();
1060
 
                if (!xmlValidation) {
1061
 
                    xmlValidation = ((Host)container).getXmlValidation();
1062
 
                }
1063
 
                
1064
 
                xmlNamespaceAware = context.getXmlNamespaceAware();
1065
 
                if (!xmlNamespaceAware){
1066
 
                    xmlNamespaceAware 
1067
 
                                = ((Host)container).getXmlNamespaceAware();
1068
 
                }
1069
 
 
1070
 
                container = container.getParent();
1071
 
            }
1072
 
        }
1073
 
 
1074
1043
        // Process the default and application web.xml files
1075
1044
        defaultWebConfig();
1076
1045
        applicationWebConfig();
1222
1191
        }
1223
1192
        */
1224
1193
 
1225
 
        // Removing sercurity role
 
1194
        // Removing security role
1226
1195
        String[] securityRoles = context.findSecurityRoles();
1227
1196
        for (i = 0; i < securityRoles.length; i++) {
1228
1197
            context.removeSecurityRole(securityRoles[i]);
1261
1230
        }
1262
1231
 
1263
1232
        // Remove (partially) folders and files created by antiLocking
1264
 
        Host host = (Host) context.getParent();
1265
 
        String appBase = host.getAppBase();
1266
 
        String docBase = context.getDocBase();
1267
 
        if ((docBase != null) && (originalDocBase != null)) {
1268
 
            File docBaseFile = new File(docBase);
1269
 
            if (!docBaseFile.isAbsolute()) {
1270
 
                docBaseFile = new File(appBase, docBase);
1271
 
            }
 
1233
        if (antiLockingDocBase != null) {
1272
1234
            // No need to log failure - it is expected in this case
1273
 
            ExpandWar.delete(docBaseFile, false);
 
1235
            ExpandWar.delete(antiLockingDocBase, false);
1274
1236
        }
1275
 
        
 
1237
 
1276
1238
        ok = true;
1277
1239
 
1278
1240
    }
1279
 
    
1280
 
    
 
1241
 
 
1242
 
1281
1243
    /**
1282
1244
     * Process a "destroy" event for this Context.
1283
1245
     */
1291
1253
        if (workDir != null)
1292
1254
            ExpandWar.delete(new File(workDir));
1293
1255
    }
1294
 
    
1295
 
    
 
1256
 
 
1257
 
1296
1258
    /**
1297
1259
     * Validate the usage of security role names in the web application
1298
1260
     * deployment descriptor.  If any problems are found, issue warning
1309
1271
            for (int j = 0; j < roles.length; j++) {
1310
1272
                if (!"*".equals(roles[j]) &&
1311
1273
                    !context.findSecurityRole(roles[j])) {
1312
 
                    log.info(sm.getString("contextConfig.role.auth", roles[j]));
 
1274
                    log.warn(sm.getString("contextConfig.role.auth", roles[j]));
1313
1275
                    context.addSecurityRole(roles[j]);
1314
1276
                }
1315
1277
            }
1321
1283
            Wrapper wrapper = (Wrapper) wrappers[i];
1322
1284
            String runAs = wrapper.getRunAs();
1323
1285
            if ((runAs != null) && !context.findSecurityRole(runAs)) {
1324
 
                log.info(sm.getString("contextConfig.role.runas", runAs));
 
1286
                log.warn(sm.getString("contextConfig.role.runas", runAs));
1325
1287
                context.addSecurityRole(runAs);
1326
1288
            }
1327
1289
            String names[] = wrapper.findSecurityReferences();
1328
1290
            for (int j = 0; j < names.length; j++) {
1329
1291
                String link = wrapper.findSecurityReference(names[j]);
1330
1292
                if ((link != null) && !context.findSecurityRole(link)) {
1331
 
                    log.info(sm.getString("contextConfig.role.link", link));
 
1293
                    log.warn(sm.getString("contextConfig.role.link", link));
1332
1294
                    context.addSecurityRole(link);
1333
1295
                }
1334
1296
            }
1341
1303
     * Get config base.
1342
1304
     */
1343
1305
    protected File getConfigBase() {
1344
 
        File configBase = 
 
1306
        File configBase =
1345
1307
            new File(System.getProperty("catalina.base"), "conf");
1346
1308
        if (!configBase.exists()) {
1347
1309
            return null;
1348
1310
        } else {
1349
1311
            return configBase;
1350
1312
        }
1351
 
    }  
1352
 
 
1353
 
    
 
1313
    }
 
1314
 
 
1315
 
1354
1316
    protected String getHostConfigPath(String resourceName) {
1355
1317
        StringBuffer result = new StringBuffer();
1356
1318
        Container container = context;
1374
1336
    }
1375
1337
 
1376
1338
 
 
1339
    /**
 
1340
     * @deprecated Unused. Use {@link XmlErrorHandler}. Will be removed in
 
1341
     *             Tomcat 7.0.x
 
1342
     */
 
1343
    @Deprecated
1377
1344
    protected class ContextErrorHandler
1378
1345
        implements ErrorHandler {
1379
1346
 
1391
1358
 
1392
1359
    }
1393
1360
 
1394
 
 
1395
1361
}