Bug 64871

Summary: warn "SEVERE" if /WEB-INF/web.xml not found
Product: Tomcat 9 Reporter: Ralf Hauser <hauser>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 9.0.x   
Target Milestone: -----   
Hardware: PC   
OS: Linux   

Description Ralf Hauser 2020-11-04 14:37:42 UTC
org.apache.catalina.startup.ContextConfig.getContextWebXmlSource() normally doesn't follow symlinks.
So, if the Constants.ApplicationWebXml i.e. "/WEB-INF/web.xml" due to this cannot be read, 
1) mention the full path where you were looking in an error message
2) put this as "SEVERE" in the catalina out log


Otherwise, you can waste hours with 

<<HTTP Status 404 – Not Found

Type Status Report

Message /index_en.jsp;jsessionid=A3944DE3830D9AF59D3970DDBA

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.>>
Comment 1 Ralf Hauser 2020-11-04 14:40:23 UTC
the root cause probably was that in server.xml, the path to 

<Context path=""
docBase="/home/me/dir/app/" reloadable="true"
workDir=...

was after change pointing to a symLink.

(using tomcat inside the IDE)
Comment 2 Mark Thomas 2020-11-06 14:18:40 UTC
The previous issue hadn't been forgotten. I'll mark it as a duplicate of this one shortly.

Since the original issue was raised, the resource handling has been significantly refactored. It looks like it will be possible to catch files being ignored because of symlinks in a single place.

It seems unlikely to me that users would want a symlink to be ignored otherwise why create the symlink in the fist place? I am therefore experimenting with logging an error message whenever a file is ignored due to it being accessed via a symlink.

I do think SEVERE is too excessive for the general case. It is probably appropriate for some files (like web.xml) but I don't want to start down the path of checking for files names before deciding on the log level. WARN seems reasonable.
Comment 3 Mark Thomas 2020-11-06 14:18:46 UTC
*** Bug 57892 has been marked as a duplicate of this bug. ***
Comment 4 Ralf Hauser 2020-11-06 15:38:49 UTC
Thanks - I agree that a "SEVERE" for every symlink file is too much.

But if it is for the Context's "docBase" and "workDir" which essentially means that an entire web app will not start, it really should be SEVERE !

Especially because the error message visible is really not helpful to find the cause
Comment 5 Mark Thomas 2020-11-06 18:56:34 UTC
What I am trying to avoid is an every increasing list of "critical" file names. Logging at error (SEVERE) if the path starts with /WEB-INF or /META-INF should catch all the important config files.
Comment 6 Mark Thomas 2020-11-06 19:26:35 UTC
Fixed in:
- 10.0.x for 10.0.0-M10 onwards
- 9.0.x for 9.0.40 onwards
- 8.5.x for 8.5.60 onwards
- 7.0.x for 7.0.107 onwards