2

About installing archiva, followed

http://archiva.apache.org/docs/2.2.3/adminguide/webapp.html

<Context path="/archiva"
          docBase="${catalina.home}/archiva/apache-archiva-2.2.3.war">

 <Resource name="jdbc/users" auth="Container" type="javax.sql.DataSource"
           username="archiva"
           password="123456"
           driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://localhost:3306/archiva?useSSL=false" />

 <Resource name="mail/Session" auth="Container"
            type="javax.mail.Session"
            mail.smtp.host="localhost"/>
</Context>

The war is deployed to Tomcat 8.0.26.

If I change the context path from /archiva to /mavenRepos, it will not work.

19-Mar-2018 10:49:32.603 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [E:\apache-tomcat-9.0.6\conf\Catalina\localhost\archiva.xml]
19-Mar-2018 10:49:32.638 WARNING [main] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/mavenRepos] in deployment descriptor [E:\apache-tomcat-9.0.6\conf\Catalina\localhost\archiva.xml] has been ignored

Why the context path is ignored?

eastwater
  • 4,624
  • 9
  • 49
  • 118

1 Answers1

5

This warning is being logged by https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/startup/HostConfig.java#L581 and it means that tomcat is not using the path attribute of the Context, so you may as well remove it.

Why isn't tomcat using it?

According to https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Common_Attributes, the path attribute is:

The context path of this web application, which is matched against
the beginning of each request URI to select the appropriate web
application for processing. All of the context paths within a
particular Host must be unique. If you specify a context path
of an empty string (""), you are defining the default web application
for this Host, which will process all requests not assigned to other Contexts.

This attribute must only be used when statically defining a Context
in server.xml. In all other circumstances, the path will be inferred
from the filenames used for either the .xml context file or the docBase.

Even when statically defining a Context in server.xml, this attribute must
not be set unless either the docBase is not located under the Host's appBase
or both deployOnStartup and autoDeploy are false. If this rule is not
followed, double deployment is likely to result.

This means that every request that your server receives is checked to see if the URL starts with /mavenRepos. If it does, it is handed off to this context.

However, you've declared this Context somewhere that it's too late to match against /mavenRepos, because tomcat has already decided which Context to hand off the request to before it gets here. Note the second paragraph above: This attribute must only be used when statically defining a Context in server.xml.

Anywhere else that you define the path, tomcat has already inferred the path from the filename before loading the file.

Isaac Betesh
  • 2,935
  • 28
  • 37