eclipse 无法执行目标 tomcat:deploy 写入服务器时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25183408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to execute goal tomcat:deploy Error writing to server
提问by med_alpa
I'm trying to test a spring-mvc tutorial here.
我正在尝试在此处测试 spring-mvc 教程。
I would like to deploy the generated war on tomcat 7 using eclipse-maven.
我想使用 eclipse-maven 在 tomcat 7 上部署生成的War。
The war works fine when deployed manually on tomcat.
在 tomcat 上手动部署时,War工作正常。
Steps to follow :
要遵循的步骤:
- import project on eclipse
add this plugin to the existing POM:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <mode>war</mode> <url>http://localhost:8080/manager/html/</url> <server>TomcatServer</server> <path>/springexample</path> </configuration>
configure a new tomcat server in eclipse with the name TomcatServer
- 在 Eclipse 上导入项目
将此插件添加到现有 POM:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <mode>war</mode> <url>http://localhost:8080/manager/html/</url> <server>TomcatServer</server> <path>/springexample</path> </configuration>
在 Eclipse 中配置一个名为 TomcatServer 的新 tomcat 服务器
modify the tomcat-users.xml file: include an admin user:
修改 tomcat-users.xml 文件:包含一个管理员用户:
<tomcat-users>
<role rolename="admin"/>
<role rolename="standard"/>
<role rolename="manager-gui"/>
<role rolename="manager"/>
<role rolename="tomcat"/>
<role rolename="manager-script"/>
<user password="password" roles="standard,manager,admin,manager-gui,manager-script,tomcat" username="admin"/>
</tomcat-users>
Add the server configuration to the setting.xml config file under .m2 user folder:
TomcatServer admin password
Strat tomcat server
将服务器配置添加到 .m2 用户文件夹下的 setting.xml 配置文件中:
Tomcat服务器管理员密码
Strat Tomcat 服务器
When I execute the following goals :
当我执行以下目标时:
Maven generate-sources : to generate the war file
Maven generate-sources : 生成war文件
then Run configuration --> with the goal :
然后运行配置 --> 目标:
tomcat:deploy
tomcat:部署
the error is :
错误是:
[
[
ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project springexample: Cannot invoke Tomcat manager: Error writing to server -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project springexample: Cannot invoke Tomcat manager at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149) at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.io.IOException: Error writing to server at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604) at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662) at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295) at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85) at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85) at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141) ... 22 more [ERROR] [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
错误] 无法在项目 springexample 上执行目标 org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli):无法调用 Tomcat 管理器:写入服务器时出错 -> [帮助 1] org.apache.maven .lifecycle.LifecycleExecutionException:无法在项目 springexample 上执行目标 org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli):无法在 org.apache.maven.lifecycle.internal.MojoExecutor 上调用 Tomcat 管理器。在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 执行(MojoExecutor.java:217)在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder。buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 在 org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 在 org.apache.maven.cli.MavenCli.execute(MavenCli.java) :537) 在 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 在 org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus。plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 在 org.codehaus.plexus.classworlds.launcher.Launcher。 mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 引起:org.apache.maven.plugin.MojoExecutionException:无法在 org.codehaus 调用 Tomcat 管理器.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149) 在 org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70) 在 org.apache.maven.plugin.DefaultBuildPluginManager. :101) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 更多 引起:java.io。IOException: 在 sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source) at sun.net.www.protocol 写入服务器时出错.http.HttpURLConnection.getInputStream(Unknown Source) at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604) at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662) at org .codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295) 在 org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85) 在 org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo. .java:85) 在 org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141) ...22 more [ERROR] [ERROR] [ERROR] 更多错误信息和可能的解决方法,请阅读以下文章:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
回答by Etienne Tonnelier
In my case, using the tomcat7 command for deployment worked :
就我而言,使用 tomcat7 命令进行部署有效:
tomcat7:deploy
And you should not use :
你不应该使用:
tomcat:deploy
回答by DD.
My issue was related to the fact the WAR file was over 50mb. You need to set the config in web.xml from the tomcat manager.
我的问题与 WAR 文件超过 50mb 的事实有关。您需要在 tomcat 管理器的 web.xml 中设置配置。
The file will normally be in %tomcat installation%\webapps\manager\WEB-INF\web.xml
该文件通常位于 %tomcat 安装%\webapps\manager\WEB-INF\web.xml
<multipart-config>
<!-- 50MB max -->
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
回答by Tony BenBrahim
You should focus your effors on
你应该把精力集中在
Caused by: java.io.IOException: Error writing to server
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604)
Look at the source for TomcatManager (http://mojo.codehaus.org/tomcat-maven-plugin/xref/org/codehaus/mojo/tomcat/TomcatManager.html#672)
查看 TomcatManager 的源代码(http://mojo.codehaus.org/tomcat-maven-plugin/xref/org/codehaus/mojo/tomcat/TomcatManager.html#672)
The maven plugin cannot read from the server. It connects, line 597, it writes the data, line 601, but fails when it reads the response, line 604
Maven 插件无法从服务器读取。它连接,第 597 行,写入数据,第 601 行,但在读取响应第 604 行时失败
I would try to deploy at the server first (to get rid of network problems) and see if the problem persists.
我会先尝试在服务器上部署(以摆脱网络问题),看看问题是否仍然存在。