【问题标题】:Maven auto deployment to tomcat6 failure, deploying to incorrect URLMaven自动部署到tomcat6失败,部署到错误的URL
【发布时间】:2015-08-09 11:17:50
【问题描述】:


我正在尝试使用 tomcat-maven-plugin6 将 war 文件自动部署到 apache-tomcat-server(6.0.33),但在 tomcat:deploy 命令上,maven(3.5.1/1.5.1. xxx EclipseIDE-embedded) 试图安装到不正确的 URL (localhost:8080/webapplication),我在这里看到了类似的问答 (1,2) 但它的答案并没有解决我的问题.请在下面找到更多详细信息。

Settings.xml

  <servers>
    <server>
      <id>localhost</id>
      <username>admin</username>
      <password>admin</password>
    </server>
  </servers>

pom.xml

<plugin>
    <groupId> org.apache.tomcat.maven</groupId>
    <artifactId>tomcat6-maven-plugin</artifactId>
    <version>2.0-beta-1</version>
    <configuration>
        <url>http://localhost:8080/manager</url>
        <!-- <username>usr</username> <password>pwd</password> -->
        <server>localhost</server>
        <path>/datatest</path>
        <warFile>target/service-manager.war</warFile>
    </configuration>
</plugin>

Maven 控制台:

[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ service-manager <<<
[INFO] 
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) @ service-manager ---
[INFO] Deploying war to http://localhost:8080/service-manager  
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Data manager ...................................... SUCCESS [  7.454 s]
[INFO] Business Manager .................................. SUCCESS [  0.109 s]
[INFO] Core module ....................................... SUCCESS [  6.699 s]
[INFO] Booter Application ................................ SUCCESS [  1.016 s]
[INFO] Booter Service Webapp ............................. FAILURE [ 33.289 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 49.099 s
[INFO] Finished at: 2015-08-09T16:09:15+05:30
[INFO] Final Memory: 21M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project service-manager: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/deploy?path=%2Fservice-manager&war= -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project service-manager: Cannot invoke Tomcat manager

【问题讨论】:

  • 同时设置&lt;warFile&gt;&lt;path&gt; 可能会混淆插件并导致它忽略&lt;path&gt; 提及(我同意 - 它不应该真的这样编码)。在您的情况下,war 似乎位于默认位置并具有默认名称,因此请尝试删除 &lt;warFile&gt; 提及,看看它是否会导致 &lt;path&gt; 设置不被忽略。

标签: java eclipse maven tomcat deployment


【解决方案1】:

我认为 url 应该是 http://localhost:8080/manager/text(你错过了 /text)。

【讨论】:

  • 我认为tomcat6:localhost:8080/manager和tomcat7:localhost:8080/manager/text是URL如果我错了请纠正我。
  • 对不起,你是对的 - /manager/text 是 tomcat7 的 url。对此感到抱歉。我认为@mystarrocks 的答案可能是正确的——尽量不要同时使用 path 和 warFile。
【解决方案2】:

我有同样的行为,也许你试图调用 错误的 maven 目标

首先确保您的用户名和密码是根据 Tomcat conf/tomcat-users.xml 配置通知的。

其次,如果您在 Tomcat 6 上进行部署,请尝试使用 tomcat6:deploytomcat6:redeploy 目标(而不是 tomcat:deploy)。为我工作。

一些建议:

  • 如果不是必需的,最好使用插件的最新稳定版本 2.2 http://tomcat.apache.org/maven-plugin-2.2/
  • 我从来没有使用过warFile 属性,你使用它是因为目标文件夹有几次战争吗?如果不是,则不必指定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-29
    • 1970-01-01
    • 2013-06-21
    • 2010-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多