title: Ant: "IOException: Error writing request body to server" on deployment to tomcat
body: <p>I am new to StackExchange so please bear with my eventual mistakes...</p>
  
  <p>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.</p>
  
  <p>I am making a build an deployment script in ant. The deployment part is using this taskdef:</p>
  
  <pre><code>&lt;taskdef name="tomcatdeploy" classname="org.apache.catalina.ant.DeployTask" /&gt;
  &lt;target name="-tomcatdeploy" description="deploy to tomcat"&gt;
      &lt;echo&gt;deploying from client&lt;/echo&gt;
      &lt;tomcatdeploy
              url="http://32.0.26.146:8080/manager/text"
              username="&lt;veryHardToGuessUsername&gt;"
              password="&lt;veryHardToGuessPassword&gt;"
              path="/avlsweb"
              war="/mnt/s/Web/Avlsweb/BambooBuilds/TEST/${nt-server.dir.test}_Tc${version}/avlsweb##${version}.war"
              version="${version}"
              /&gt;   
  </code></pre>
  
  <p>We use Bamboo as build server. This worked fine for a number of builds. However recently I got this build error:</p>
  
  <pre><code>/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)
  </code></pre>
  
  <p>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:</p>
  
  <ul>
  <li>Tomcat manager-script user is setup</li>
  <li>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.</li>
  <li>Build server: Atlassian Bamboo 5.9.0</li>
  <li>Ant version: 1.9.2</li>
  <li>Tomcat version: 8.0.15</li>
  <li>Java version: 1.7.0_67</li>
  </ul>
  
  <p>Any ideas?</p>