Bug 49551 - When setting absolute path to default context.xml, in ContextConfig.contextConfig() it cannot be found
Summary: When setting absolute path to default context.xml, in ContextConfig.contextCo...
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.26
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2010-07-05 07:41 UTC by Violeta Georgieva
Modified: 2014-02-17 13:53 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Violeta Georgieva 2010-07-05 07:41:23 UTC

I'm using an Embedded Tomcat.
I want to use the Tomcat's functionality - default context.xml.

I'm extending the org.apache.catalina.startup.ContextConfig.
Sometimes the default context.xml is outside of the "base" directory, because of this I'm using the following method to set the location - in the java doc it is stated that an absolute path is acceptable for method parameter.


218    /**
219     * Set the location of the default context file
220     *
221     * @param path Absolute/relative path to the default context.xml
222     */
223    public void setDefaultContextXml(String path) {
225        this.defaultContextXml = path;
227    }

When ContextConfig.contextConfig() method is invoked, a wrong path is generated for the default context.xml

If the base directory is d:/base-dir
and the path to the default context.xml is d:/other-dir/configuration/context.xml

the following is generated:

This happens in ContextConfig.java:

715    /**
716     * Process the default configuration file, if it exists.
717     */
718    protected void contextConfig() {
728            processContextConfig(new File(getBaseDir()), defaultContextXml);
734    }

737    /**
738     * Process a context.xml.
739     */
740    protected void processContextConfig(File baseDir, String resourceName) {
749        File file = baseDir;
750        if (resourceName != null) {
751            file = new File(baseDir, resourceName);
752        }
819    }

Could you please clarify whether it is possible to use this setter method with absolute paths?

Thanks in advance
Comment 1 Mark Thomas 2010-07-05 17:10:22 UTC
Thanks for the bug report. I have fixed in this in 7.0.x (it will be in 7.0.1 onwards) and proposed the fix for 6.0.x.
Comment 2 Mark Thomas 2010-07-16 06:14:50 UTC
This has been fixed in 6.0.x and will be included in 6.0.29 onwards.