I'm trying to automate the deploy of my WAR in tomcat 8.0.12, by uploading the WAR using the Manager-Script servlet.
Performing a PUT to this URL:
http://tomcaserver:8080/manager/text/deploy?path=/myApp&update=true
My WAR size is about 80mb, and I think that is the problem.
I tested using a small WAR (about 500kb) and it uploads without problems.
I already tried to specify the multipart-config inside the /webapps/manager/WEB-INF/web.xml, inserting this:
<servlet>
<servlet-name>Manager</servlet-name>
<servlet-class>org.apache.catalina.manager.ManagerServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<multipart-config>
<!-- 200MB max -->
<max-file-size>209715200</max-file-size>
<max-request-size>209715200</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
</servlet>
After this, the problem continues.
I'm using Apache HTTPClient to upload and this is the exception:
Exception in thread "main" java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
at org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:123)
at org.apache.http.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:135)
at org.apache.http.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:164)
at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:120)
at org.apache.http.entity.mime.AbstractMultipartForm.doWriteTo(AbstractMultipartForm.java:150)
at org.apache.http.entity.mime.AbstractMultipartForm.writeTo(AbstractMultipartForm.java:173)
at org.apache.http.entity.mime.MultipartFormEntity.writeTo(MultipartFormEntity.java:97)
at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:155)
at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:149)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:236)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at br.com.jjw.atualizador.core.Atualizador.deploy(Atualizador.java:175)
This is my code:
String url = "http://tomcatserver:8080/manager/text/deploy?path=/organize&update=true";
HttpPut req = new HttpPut(url);
MultipartEntityBuilder meb = MultipartEntityBuilder.create();
// upload the big war (80mb)
meb.addBinaryBody("attachment", war, ContentType.APPLICATION_OCTET_STREAM, "myApp.war");
req.setEntity(meb.build());
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("tomcat", "s3cret"));
CloseableHttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
CloseableHttpResponse resp = client.execute(req); <<<---- EXCEPTION!
How can I solve this?
curlorwgetinstead of a hand-rolled client? - Christopher Schultz