我尝试将应用程序部署到tomcat7服务器时出错

时间:2014-08-16 01:12:54

标签: maven deployment tomcat7

我正在尝试通过eclipse luna将一个Web应用程序部署到tomcat7,但是我收到了这个错误:

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

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.936 s
[INFO] Finished at: 2014-08-15T22:10:04-03:00
[INFO] Final Memory: 13M/112M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project loja: Cannot invoke Tomcat manager: Connection reset -> [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

我也尝试部署到tomcat8,但我得到同样的错误。

在我的pom.xml中,我有与此操作相关的配置:

  <build>
    <finalName>loja</finalName>
    <plugins>
        <plugin>
           <groupId>org.apache.tomcat.maven</groupId>
           <artifactId>tomcat7-maven-plugin</artifactId>
           <version>2.2</version>
           <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>TomcatServer</server>
                <path>/loja</path>
                <username>user001</username>
                <password>123</password>
           </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

任何人都知道这里发生了什么?

更新

我尝试使用命令mvn:tomcat7 deploy -X部署应用程序,输出结果为:

[INFO] Retrying request
[DEBUG] Reopening the direct connection.
[DEBUG] Connecting to localhost:8080
[DEBUG] Attempt 4 to execute request
[DEBUG] Sending request: PUT /manager/text/deploy?path=%2Floja HTTP/1.1
[DEBUG]  >> "PUT /manager/text/deploy?path=%2Floja HTTP/1.1[\r][\n]"
[DEBUG]  >> "User-Agent: Apache Tomcat Maven Plugin/2.2[\r][\n]"
[DEBUG]  >> "Content-Length: 18783041[\r][\n]"
[DEBUG]  >> "Host: localhost:8080[\r][\n]"
[DEBUG]  >> "Connection: Keep-Alive[\r][\n]"
[DEBUG]  >> "Authorization: Basic dXNlcjAwMToxMjM=[\r][\n]"
[DEBUG]  >> "[\r][\n]"
[DEBUG] >> PUT /manager/text/deploy?path=%2Floja HTTP/1.1
[DEBUG] >> User-Agent: Apache Tomcat Maven Plugin/2.2
[DEBUG] >> Content-Length: 18783041
[DEBUG] >> Host: localhost:8080
[DEBUG] >> Connection: Keep-Alive
[DEBUG] >> Authorization: Basic dXNlcjAwMToxMjM=
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
...
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 closed
[DEBUG] Closing the connection.
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 closed
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 shut down
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 closed
[DEBUG] Connection released: [id: 0][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 5]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.271 s
[INFO] Finished at: 2014-08-16T08:11:09-03:00
[DEBUG] Connection manager is shutting down
[INFO] Final Memory: 14M/109M
[INFO] ------------------------------------------------------------------------
[DEBUG] Connection manager shut down

11 个答案:

答案 0 :(得分:15)

好的,我和tomcat7有同样的问题。

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2iplover

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2iplover

[INFO] I/O exception (java.net.SocketException) caught when processing request:         Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2iplover

我无法使用

mvn tomcat7:redeploy 

如上所述here

我的WAR不是很大,只有4MB。

这是根本问题和解决方案

您的tomcat-users.xml设置正确的角色非常重要。我只有manager角色设置。添加manager-script似乎很重要,完全解决了我的问题。

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

答案 1 :(得分:13)

我不知道是否有人解决了这个问题。我在我的案例中找到了一种解决方法:使用redeploy而不是部署工作正常。

问题可能与内存问题或读/写访问有关?

答案 2 :(得分:10)

你的战争规模是多少?也许是因为尺寸太大了。默认情况下,tomcat管理器只允许小于50MB的大小战争。也可以尝试mvn tomcat7:redeploy而不是deploy。

See here how to increase the war size limit

答案 3 :(得分:10)

默认情况下,Tomcat的最大上传大小为50MB。 (即WAR文件的最大大小)

如果您需要更大的文件,请尝试在tomcat max-file-size中增加max-request-sizeweb.xml。注意:这些值都以字节存储。

修改.../webapps/manager/WEB-INF/web.xml。 (确保文件大小大于您尝试上传的war文件。即如果你需要80MB WAR,

  <max-file-size>82914560</max-file-size>
  <max-request-size>82914560</max-request-size>

然后重启apache tomcat。

https://octopus.com/blog/tomcat-manager-deployment

答案 4 :(得分:7)

我遇到了同样的问题并通过运行maven目标来解决它

  

tomcat7:redeploy

而不是

  

tomcat7:部署

它适用于tomcat7和tomcat8,我的war文件总是低于50mb。

答案 5 :(得分:2)

检查〜/ .m2 / settings.xml

<settings>
  <servers>
    <server>
      <id>tomcat-manager</id>
      <username>user001</username>
      <password>123</password>
    </server>
  </servers>
</settings>

答案 6 :(得分:2)

我遇到了同样的问题,在我的情况下,问题是一个不以/开头的cunfigured上下文路径。 将上下文路径“myapp”修复为“/ myapp”解决了这个问题。

答案 7 :(得分:2)

偶尔出现问题

如果有时重新部署失败,有时会成功,增加日志记录可能会显示DOS保护。

修改/conf/logging.properties并添加第

org.apache.catalina.level = FINEST

在文件的末尾。可能会显示此输出:

FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke Security checking request PUT /manager/text/deploy
FINE [http-nio-8080-exec-7] org.apache.catalina.loader.WebappClassLoaderBase.loadClass loadClass(org.apache.catalina.manager.ManagerServlet, false)
FINE [http-nio-8080-exec-7] org.apache.catalina.loader.WebappClassLoaderBase.loadClass   Delegating to parent classloader1 java.net.URLClassLoader@568db2f2
FINE [http-nio-8080-exec-7] org.apache.catalina.loader.WebappClassLoaderBase.loadClass   Loading class from parent
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against PUT /text/deploy --> true
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against PUT /text/deploy --> true
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke  Calling hasUserDataPermission()
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.hasUserDataPermission   User data constraint has no restrictions
FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke  Calling authenticate()
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.CombinedRealm.authenticate Attempting to authenticate user [admin] with realm [org.apache.catalina.realm.UserDatabaseRealm]
FINER [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.authenticate Username [admin] NOT successfully authenticated
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.CombinedRealm.authenticate Failed to authenticate user [admin] with realm [org.apache.catalina.realm.UserDatabaseRealm]
WARNING [http-nio-8080-exec-7] org.apache.catalina.realm.LockOutRealm.filterLockedAccounts 
     An attempt was made to authenticate the locked user [admin]
FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke  Failed authenticate() test
FINE [http-nio-8080-exec-7] org.apache.catalina.core.StandardHostValve.custom Processing ErrorPage[errorCode=401, location=/WEB-INF/jsp/401.jsp]
FINER [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapper.allocate   Returning non-STM instance
FINE [http-nio-8080-exec-7] org.apache.catalina.core.ApplicationDispatcher.doForward  Disabling the response for further output

(在此日志记录中,尝试上传的用户具有用户名admin

正如您在此输出中看到的,用户admin已被锁定:

WARNING [http-nio-8080-exec-7] org.apache.catalina.realm.LockOutRealm.filterLockedAccounts 
  An attempt was made to authenticate the locked user [admin]

查看documentationserver.xml内部,您会找到

   <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
           resourceName="UserDatabase"/>

使用不可预见的用户名

要删除该行是一个坏主意,请将重新部署的用户名更改为其他更不可预见的名称,例如deploy355547511,以免被锁定。

答案 8 :(得分:0)

我不知道这是否有帮助,但在我的情况下。 tomcat7插件从maven conf settings.xml中选择服务器详细信息,而不是从.m2 \ settings.xml。 在该文件中添加服务器信息已解决我的问题。

答案 9 :(得分:0)

就我的AWS亚马逊实例而言,原因是:

磁盘空间已满 注意我的EC2现场实例上的99%

通常使用此命令使用jenkins

 mvn clean tomcat7:redeploy -Ddeploy.password=xxxAG1
 -Ddeploy.username=admin -Ddeploy.context=/v1 -Ddeploy.url=http://localhost:8080/manager/text

enter image description here

释放这个空间,它与我合作。

我遇到的错误是

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request


[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.914 s
[INFO] Finished at: 2018-01-10T08:38:28+00:00
[INFO] Final Memory: 47M/371M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy (default-cli) on project XXXX-app: Cannot invoke Tomcat manager: Connection reset -> [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.

提示使用此命令 从(command is from stackoverflow)追踪你的空间是什么 sudo du -x -d1 -h /

答案 10 :(得分:0)

使用Maven tomcat插件重新部署对我来说也失败了,这是因为客户端上的连接重置以及Tomcat 8.5.30上localhost_access.log中的403状态代码。

此Tomcat版本的管理器应用程序默认情况下配置了RemoteAddrValve,以限制对/ manager / *本地主机路径的访问。参见$TOMCAT_HOME/webapps/manager/META-INF/context.xml

它有助于turn on the logging找到the solution to this