1

I am using Ant to deploy a war to a Tomcat server, but it gives me the following error:

    BUILD FAILED
    /home/deploy/Documents/Work/Deploy_Wars/xrepo/deployment/build.xml:37: The following error occurred while executing this line:
    /home/deploy/Documents/Work/Deploy_Wars/xrepo/deployment/ant_scripts/deploy_wars.xml:36: The following error occurred while executing this line:
    /home/deploy/Documents/Work/Deploy_Wars/xrepo/deployment/ant_scripts/deploy_wars.xml:42: java.io.IOException: Error writing to server
        at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:699)
        at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:711)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1585)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
        at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:223)
        at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:201)
        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:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:350)
        at org.apache.tools.ant.Target.execute(Target.java:448)
        at org.apache.tools.ant.Target.performTasks(Target.java:469)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:446)
        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)

Here is the Ant target that I use for this deployment (and here is the line where the exception is thrown):

    <target name="deploy-debug" description="Install DEBUG">
        <deploy url="http://debug.webiste.ro:8180/manager" username="admin" password="password"
                path="/debug-war" war="wars/debug-war.war"/>
    </target>

I am using Tomcat 9.0.10 and Ant 1.10.3 on Ubuntu 18.04.

I saw some people suggesting that the tomcat user is not properly defined in tomcat_users.xml. I have modified it, but it still gives me the exception when I try to deploy. I can succsefully login on the Tomcat manager app in the browser. Here is my tomcat_users.xml:

    <tomcat-users xmlns="http://tomcat.apache.org/xml"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
          version="1.0">
          <role rolename="tomcat"/>
          <role rolename="manager-script"/>
          <role rolename="manager-gui"/>
          <role rolename="admin-gui"/>
          <role rolename="admin-script"/>
          <user username="admin" password="password" roles="manager-gui,manager-script,admin-gui,admin-script"/>
    </tomcat-users>

The war file that I am trying to deploy has 80 Mb which is bigger than the default maximum upload value of Tomcat (50 Mb). I have tried increasing the maximum upload value to 100 Mb but it still gives me the Exception.

Any ideas on this problem?

1 Answers1

1

It could be disk space, or hot deploy. For hot deploy, you can put the following parameters:

...
<target name="tomcat-stop">
    <exec executable="${server.home}/bin/catalina.bat">
        <arg value="stop"/>
    </exec>
</target>

<target name="tomcat-start">
    <exec executable="${server.home}/bin/startup.bat">
        <arg value="start"/>
    </exec>
</target>
...
<target name="all" depends="tomcat-stop,clean,init,compile,junit-slow,make_war,deploy,tomcat-start"></target>

The answer is at this link: https://stackoverflow.com/a/32482795/8442153

dalmo.santos
  • 146
  • 5