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...
Status: RESOLVED FIXED
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
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-05 07:41 UTC by Violeta Georgieva
Modified: 2014-02-17 13:53 UTC (History)
0 users



Attachments

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
Hi,

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.

http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_26/java/org/apache/catalina/startup/ContextConfig.java

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) {
224
225        this.defaultContextXml = path;
226
227    }

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

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:
d:/base-dir/d:/other-dir/configuration/context.xml

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
Regards
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.