Bug 57723

Summary: An incomplete fix for invalid context paths in StandardContext.java / JNDI fails
Product: Tomcat 7 Reporter: Christian Kahlo <ck>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P2    
Version: 7.0.59   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Christian Kahlo 2015-03-18 04:49:24 UTC
The fix for #57216 is aimed handle invalid context paths, such as "/".
When using Tomcat.addWebapp() the (wrong) name for the context is
already set in Line 534.

    public Context addWebapp(Host host, String url, String path) {
        return addWebapp(host, url, url, path);
    }
			
    public Context addWebapp(Host host, String url, String name, String path) {
        silence(host, url);
        Context ctx = createContext(host, url);
        ctx.setName(name);
        ctx.setPath(url);
        ctx.setDocBase(path);
...

Therefore StandardContext.setPath()#2198 does not set the corrected name for the
context.

This causes JNDI to fail, i.e. in JSPCompilationContext.getLastModified()#410 and
#421.

if(invalid) should also include setting the new corrected name.
Or fail hard - that would have made it easier to find.

Best regards,
Christian
Comment 1 Mark Thomas 2015-03-19 14:29:22 UTC
Fixed in 7.0.x for 7.0.60 onwards.