Created attachment 24967 [details] patch (diffed from org/apache/catalina/ant) I consistently get OutOfMemory errors when attempting to deploy a 70 mb WAR file to Tomcat using the Deploy ant task: java.lang.OutOfMemoryError: Java heap space at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:262) at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:201) at com.flyer.izpack.webapp.Deploy.run(Deploy.java:68) 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 com.izforge.izpack.installer.ProcessPanelWorker$ExecutableClass.run(Unknown Source) at com.izforge.izpack.installer.ProcessPanelWorker$ProcessingJob.run(Unknown Source) at com.izforge.izpack.installer.ProcessPanelWorker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Unknown Source) at java.io.ByteArrayOutputStream.write(Unknown Source) at sun.net.www.http.PosterOutputStream.write(Unknown Source) at java.io.BufferedOutputStream.write(Unknown Source) at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:215) ... 10 more --- Nested Exception --- java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Unknown Source) at java.io.ByteArrayOutputStream.write(Unknown Source) at sun.net.www.http.PosterOutputStream.write(Unknown Source) at java.io.BufferedOutputStream.write(Unknown Source) at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:215) at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:201) at com.flyer.izpack.webapp.Deploy.run(Deploy.java:68) 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 com.izforge.izpack.installer.ProcessPanelWorker$ExecutableClass.run(Unknown Source) at com.izforge.izpack.installer.ProcessPanelWorker$ProcessingJob.run(Unknown Source) at com.izforge.izpack.installer.ProcessPanelWorker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) I've tracked the issue to the use of java.net.HttpURLConnection without setting the contentLength (in some cases) and not using 'fixed length streaming mode' when contentLength is available. I'm attaching a patch that works for me with the DeployTask. I know that org.apache.catalina.ant.AbstractCatalinaTask is subclassed by many tasks, but I haven't tested all of those. I can probably provide some code to reproduce if needed. See also: https://issues.apache.org/bugzilla/show_bug.cgi?id=47660
Thanks for the patch. I've applied it to trunk and proposed it for 6.0.x
This may be completely irrelevant in this case, but just in case, the Javadoc for HttpURLConnection has the following comment: "When output streaming is enabled, authentication and redirection cannot be handled automatically." [This was suggested as a solution for preventing OOM in JMeter file uploads. Not used it yet, as it would need to be optional.]
This has been fixed in 6.0.x and will be included in 6.0.25 onwards. Thanks again for the patch.