Bug 62172 - org.apache.catalina.startup.Constants specifies an absolute path for web.xml
Summary: org.apache.catalina.startup.Constants specifies an absolute path for web.xml
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.x-trunk
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-12 08:12 UTC by Alexander Veit
Modified: 2018-04-03 17:38 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Veit 2018-03-12 08:12:39 UTC
The value of org.apache.catalina.startup.Constants.ApplicationWebXml is "/WEB-INF/web.xml".

This is an absolute path. Consequently at least the Java NIO API resolves it to the absolute path /WEB-INF/web.xml. The same holds for the WarTracker constant.

All other constants in the class are specify relative paths:

ApplicationContextXml = "META-INF/context.xml"
ApplicationWebXml     = "/WEB-INF/web.xml"
DefaultContextXml     = "conf/context.xml"
DefaultWebXml         = "conf/web.xml"
HostContextXml        = "context.xml.default"
HostWebXml            = "web.xml.default"
WarTracker            = "/META-INF/war-tracker"
Comment 1 Remy Maucherat 2018-03-12 09:02:11 UTC
Can you clarify what is wrong and where ? These constants are not all used in the same context, and some need to be absolute path, others not. For starters, ApplicationWebXml="/WEB-INF/web.xml" is correct.
Comment 2 Alexander Veit 2018-03-12 10:33:03 UTC
In our code which embeds Tomcat, I've used

Path dirDocBase;

.. = dirDocBase.resolve(Constants.ApplicationWebXml);

It resolves to /WEB-INF/web.xml which is an absolute path, starting at the root of the file system.

But maybe the constant class is intended for internal use only. Then I would be fine with not using this class.
Comment 3 Mark Thomas 2018-03-12 13:14:37 UTC
That constants class has evolved over time based on how the constants were used. The constants are correct and - in any case - can't easily be changed without breaking the potential usage of them by others.

I did notice a couple of usages of the constants are aren't quite right. Those we should clean up.

I don't like the inconsistency between ApplicationContextXml and ApplicationWebXml but I'm not sure it is worth fixing at this point.
Comment 4 Christopher Schultz 2018-03-12 15:47:02 UTC
Sounds like a documentation bug, if anything.
Comment 5 Mark Thomas 2018-04-03 17:38:19 UTC
Comments improved and a couple of incorrect usages fixed.

Fixed in:
- trunk for 9.0.7 onwards
- 8.5.x for 8.5.30 onwards
- 8.0.x for 8.0.51 onwards
- 7.0.x for 7.0.86 onwards