【问题标题】:Archiva context path is ignored on TomcatTomcat 上忽略 Archiva 上下文路径
【发布时间】:2018-03-19 14:56:13
【问题描述】:

关于安装archiva,跟着

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>

战争部署到Tomcat 8.0.26。

如果我将上下文路径从 /archiva 更改为 /mavenRepos,它将不起作用。

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

为什么忽略上下文路径?

【问题讨论】:

    标签: tomcat archiva


    【解决方案1】:

    https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/startup/HostConfig.java#L581 正在记录此警告,这意味着 tomcat 没有使用 Context 的路径属性,因此您不妨将其删除。

    为什么tomcat不使用它?

    根据https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Common_Attributes,path属性为:

    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.
    

    这意味着检查您的服务器收到的每个请求,以查看 URL 是否以 /mavenRepos 开头。如果是,则将其移交给此上下文。

    然而,你已经在某个地方声明了这个上下文,它与/mavenRepos 匹配为时已晚,因为在请求到达之前,tomcat 已经决定将请求交给哪个上下文。注意上面的第二段:This attribute must only be used when statically defining a Context in server.xml.

    在您定义路径的其他任何地方,tomcat 在加载文件之前已经从文件名推断出路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 2019-04-22
      • 2011-01-02
      • 1970-01-01
      • 2016-04-03
      • 1970-01-01
      • 2011-02-06
      相关资源
      最近更新 更多