Bug 58754

Summary: WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
Product: Tomcat 8 Reporter: gavenkoa <gavenkoa>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED INVALID    
Severity: normal CC: gavenkoa
Priority: P2    
Version: 8.0.30   
Target Milestone: ----   
Hardware: PC   
OS: Linux   

Description gavenkoa 2015-12-19 09:40:27 UTC
I get warning:

org.apache.catalina.core.StandardContext setPath
WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []

for web.xml:

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

and project dependencies:

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

Servlet 3.0 specification in section: "12.2 Specification of Mappings" say:

  A string containing only the ’ / ’ character indicates the "default" servlet 
  of the application. In this case the servlet path is the request URI minus 
  the context path and the path info is null.

The Java EE 6 platform requires Servlet 3.0.

So warning misleading and wrong according to specification semantic.
Comment 1 gavenkoa 2015-12-19 09:50:21 UTC
Hm... Seems I am wrong.

Further investigation shown that my web.xml file have:

  <web-app version="2.5">

After changing to:

  <web-app version="3.0">

I am no longer have such warning.

***I may suggest to update warning text by pointing to current Servlet API level***

That would help troubleshoot a lot.
Comment 2 Mark Thomas 2015-12-19 09:57:31 UTC
This has nothing to do with web.xml. It is triggered by an invalid path specified for a Context element. Further assistance is avaialble in the users mailing list if required.
Comment 3 gavenkoa 2015-12-19 11:03:07 UTC
Thanks for support!

This your help I discover that Debian package maintainers supply /usr/share/tomcat8-root/default_root/META-INF/context.xml with content:

  <Context path="/" 
    antiResourceLocking="false" />

That warning shown only during Tomcat restart, so I wrongly interpret results of my application hot redeploys.

Filed to Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808378

Just for future reference, docs say:

  https://tomcat.apache.org/tomcat-8.0-doc/config/context.html

  If the context path is the empty string them the base name will be ROOT
  (always in upper case) otherwise the base name will be the context path with
  the leading '/' removed and any remaining '/' characters replaced with '#'.

Using "/" as path may result that context will not be deployed:

  http://stackoverflow.com/questions/7276989/howto-set-the-context-path-of-a-web-application-in-tomcat-7-0