Monday, January 11, 2016

java.net.ProtocolException: Did not meet stated content length of OutputStream

We were getting this error:
java.net.ProtocolException: Did not meet stated content length of OutputStream:  you wrote 139 bytes and I was expecting  you to write exactly 153 bytes!!!
                at weblogic.net.http.ContentLengthOutputStream.close(ContentLengthOutputStream.java:52)
                at java.io.FilterOutputStream.close(FilterOutputStream.java:160)



There are a number of posts suggesting that one needs to change encoding.... also the Oracle doc "ProtocolException is thrown if multibyte characters is specified for HttpServletResponse.sendError method (Doc ID 1902525.1)" suggests the same.
However in our case upgrading the JVM fixed the issue. Probably the communication was happening between 2 versions of JVM using a different serialization strategy, who knows....
Thanks to Andrea for the resolution.

No comments: