java - maven tomcat部署产生错误

标签 java maven deployment tomcat7

我想使用 tomcat7:deploy 目标将我的 java webapp 部署到我的 tomcat 服务器中。但我收到以下错误

enter code[INFO] Deploying war to http://localhost:8080/CounterWebApp
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2500/5423 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2436/5423 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2500/5423 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2436/5423 KB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.588 s
[INFO] Finished at: 2016-12-21T10:42:39+05:30
[INFO] Final Memory: 18M/158M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project CounterWebApp: Cannot invoke Tomcat manager: Connection reset by peer: socket write error -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException here

我在浏览器上手动尝试了以下行并产生了错误

FAIL - Invalid parameters supplied for command [/deploy]

http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp

但是当我与下面的 war 文件一起指定时,它可以在浏览器中成功运行。

http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp&war=file:F:\documents\repositories\webcounter\target\CounterWebApp.war

那么是不是像tomcat7-maven-plugin犯了错误?如果是的话我将如何修复它或者我在某个地方犯了错误?

下面是我在pom文件中给出的插件标签

<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/${project.build.finalName}</path>
                </configuration>
            </plugin>

下面是我为 tomcat-users.xml 创建的 xml 文件 users

role rolename="manager-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <role rolename="admin-gui"/>
      <role rolename="admin-script"/>
      <user username="test" password="test" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

下面是我包含在 Maven settings.xml 中的内容

<server>
<id>mytomcat</id>
<username>test</username>
<password>test</password>
</server>

最佳答案

在 ${TOMCAT_HOME}/conf/Catalina/localhost/manager.xml

删除阀门周围的注释标记

<!--
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
    allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
    -->

 <Valve className="org.apache.catalina.valves.RemoteAddrValve"
    allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

然后访问http://127.0.0.1/manager/html ,您将查看经理页面

关于java - maven tomcat部署产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41255715/

相关文章:

java - 将 jar 及其依赖项打包到辅助 Artifact 中(不生成 fat jar)

java - 将 JAR 中的文件包含在依赖项目中

macos - 在 Mac OSX 上使用 Xcode4 部署和分发 OpenCV 应用程序

javascript - ionic 部署上未加载插件

deployment - 在 SPSS 18 中指定相对路径

java - java lambda 中的嵌套列表 Hashmap 处理

java - 授予权限后刷新谷歌地图(Android Java)

java.security.ProviderException : Could not derive key

java - 如何使用 JUnit 测试没有 @SpringBootApplication 的 Java Spring Boot 应用程序?

maven - Dockerfile-ARG SHA和Curl