java Ant:在部署到 tomcat 时出现“IOException:将请求正文写入服务器时出错”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31021899/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:57:04  来源:igfitidea点击:

Ant: "IOException: Error writing request body to server" on deployment to tomcat

javatomcatdeploymentantbamboo

提问by globus68

I am new to StackExchange so please bear with my eventual mistakes...

我是 StackExchange 的新手,所以请容忍我最终的错误......

I have been searching for answers but none seem to apply to my situation being that that build and deployment actually works, but the result is though an IOException at the end of the deployment call.

我一直在寻找答案,但似乎没有一个适用于我的情况,即构建和部署实际上有效,但结果是部署调用结束时出现 IOException。

I am making a build an deployment script in ant. The deployment part is using this taskdef:

我正在 ant 中构建一个部署脚本。部署部分正在使用这个 taskdef:

<taskdef name="tomcatdeploy" classname="org.apache.catalina.ant.DeployTask" />
<target name="-tomcatdeploy" description="deploy to tomcat">
    <echo>deploying from client</echo>
    <tomcatdeploy
            url="http://32.0.26.146:8080/manager/text"
            username="<veryHardToGuessUsername>"
            password="<veryHardToGuessPassword>"
            path="/avlsweb"
            war="/mnt/s/Web/Avlsweb/BambooBuilds/TEST/${nt-server.dir.test}_Tc${version}/avlsweb##${version}.war"
            version="${version}"
            />   

We use Bamboo as build server. This worked fine for a number of builds. However recently I got this build error:

我们使用 Bamboo 作为构建服务器。这适用于许多构建。但是最近我收到了这个构建错误:

/mnt/data/bamboo_home/xml-data/build-dir/AVTST-TEST15-JOB1/AvlswebScripts/Ant/build.xml:286: java.io.IOException: Error writing request body to server
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:3192)
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3175)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:242)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:195)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:440)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

The strange thing is that the build works and it also deploys fine to tomcat. However, for some reason an IOException occurs after the deployment resulting in a "red" failed build message in Bamboo. A couple of additional remarks:

奇怪的是构建可以正常工作,并且也可以很好地部署到 tomcat。但是,由于某种原因,在部署后会发生 IOException,导致 Bamboo 中出现“红色”失败的构建消息。补充几点:

  • Tomcat manager-script user is setup
  • Bamboo build server with ant is running on the same server as the targeting tomcat applicationserver however bamboo and the targeting tomcat are running as separate servers on separate ports.
  • Build server: Atlassian Bamboo 5.9.0
  • Ant version: 1.9.2
  • Tomcat version: 8.0.15
  • Java version: 1.7.0_67
  • Tomcat manager-script 用户已设置
  • 带有 ant 的 Bamboo 构建服务器与目标 tomcat 应用程序服务器在同一台服务器上运行,但是bamboo 和目标 tomcat 作为单独的服务器在不同的端口上运行。
  • 构建服务器:Atlassian Bamboo 5.9.0
  • 蚂蚁版本:1.9.2
  • Tomcat 版本:8.0.15
  • Java 版本:1.7.0_67

Any ideas?

有任何想法吗?

回答by chiranjeevigk

i think i am slow, i have faced same problem

我觉得我很慢,我遇到了同样的问题

in tomcatdeploytask instead of warmake it localWar

tomcatdeploy任务中而不是war使它localWar

回答by fiveclubs

You will get this error if you already have an instance deployed to the Tomcat server. You can set update="true"in the tomcatdeploy:

如果您已经将实例部署到 Tomcat 服务器,您将收到此错误。您可以update="true"tomcatdeploy

<tomcatdeploy
        url="http://32.0.26.146:8080/manager/text"
        username="<veryHardToGuessUsername>"
        password="<veryHardToGuessPassword>"
        path="/avlsweb"
        war="/mnt/s/Web/Avlsweb/BambooBuilds/TEST/${nt-server.dir.test}_Tc${version}/avlsweb##${version}.war"
        version="${version}"
        update="true"
        />

Another option is to explicitly undeploy and then redeploy, or use the reloadtag instead of the deploy tag.

另一种选择是显式取消部署然后重新部署,或者使用reload标签而不是部署标签。