We have a web service running on Tomcat 7 and jdk8 on production servers and it runs fine when the request size is smaller i.e. less than 1MB (checked the size of content length in the request header). The Java client sends the request with a PDF file in byte stream but whenever the size of the PDF is more than 1MB (checked with content-length in the header) given below, it sends the Internal Server Error (500) with FileNotFoundException. Below is the request header and response for your reference which is taken from the TCP Dump:
HTTP Request
POST /testserver/services/testservice HTTP/1.1
Content-Type: multipart/related;boundary="----=_Part_505_2042631364.1697622400773";type="text/xml";start="<soapPart>"
SoapAction:
User-Agent: Java/1.8.0_351
Host: 131.166.208.5:1689
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 1428936
------=_Part_505_2042631364.1697622400773
Content-Type: text/xml; charset="utf-8"
Content-Transfer-Encoding: 8bit
Content-ID: <soapPart>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body>
></env:Envelope>
------=_Part_505_2042631364.1697622400773
Content-Type: application/octet-stream
Content-ID: <123410215>
%PDF-1.7
%....
1 0 obj
HTTP Response with exception:
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Wed, 18 Oct 2023 09:46:41 GMT
Connection: close
12c
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope" xmlns=""><faultcode>S:Server</faultcode><faultstring>java.io.IOException: No such file or directory</faultstring></S:Fault></S:Body></S:Envelope>
0
.....dj4.e1...-..f.._...*..Z{
A......1X....P).E..Z{.eD..'r?...v.^.`......QQQ....o#...l..a..i.....{.\
Note: The 500 Error can be seen only in TCP Dump and localhost-access.log. No other logs are there related to this request. We tried to add logger line by line in web service application to trace the reason but couldn't see any other logs. We suspect that the tomcat is the one who is rejecting the request with 500 response code and request is not reaching the application. I found that we need to increase the post size in server.xml but default size is already 2MB and my requests are failing between 1 and 2MB size. So I don't think that's the real problem here.
We can see in the TCP Dump (also attached above) that the request is still coming on the server after sending a 500 response code. Tomcat is sending a response before reading the complete request. The problem is with the only requests having large content-length size in the header (more than 1 MB).
Is there any solution for this?