Issue with Chunked encoding in tomcat/tomee with a specific file

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
This post was updated on .
Hi, I need some help in identifying an issue with tomcat8/tomee7.02 with chunked encoding. This issue is happening only with a specific file and the same works with other application servers that i tested. There seems to be an issue specific to tomcat with this file's headers. I tried to do a save of same file using widows paint and it works without an issue. I'm using servlet to transfer the content to client using chunked encoding. I'm attaching the sample war which can be deployed in tomcat/tomee to reproduce the issue. I wrote a sample client program using http client to reproduce the issue. Below is the usage of the same. Deploy the war in tomcat/tomee. run the following commands from zip extracted location. The sample files are present in the context root of the web application. java -jar client.jar http://tomcathost:port/content/content.do?fileName=original.jpg I'm getting HTTP transfer failed: java.io.IOException: Protocol violation: Unexpected single newline character in chunk size error I tried to save copy of the original file by opening in windows paint and i don't see the issue java -jar client.jar http://tomcathost:port/content/content.do?fileName=edited.jpg No issue with this file.. Note : both original and edited files are present in context root and the output of the client program is a jpg file whose name will be current time in millis.jpg Please help me to understand the root cause of this issue and what possibly in headers of jpg encoding is causing this issue. Note : Code compiled with jdk 8 and also transfer is successful for other files whose size is very less or huge also ChunkedEncodingIssue.zip <http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip> -- Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

Cesar Hernandez
Hi,
Can you please provide the code of your war file example, maybe a public
github repo can work. Attachments are not transferred to the mailing list.
Also, any stack trace can provide more visibility to the list too.

El mar., 5 nov. 2019 a las 3:15, mshvr (<[hidden email]>)
escribió:

> Hi,
> I need some help in identifying an issue with tomcat8/tomee7.02 with
> chunked
> encoding. This issue is happening only with a specific file and the same
> works with other application servers that i tested. There seems to be an
> issue specific to tomcat with this file's headers. I tried to do a save of
> same file using widows paint and it works without an issue. I'm using
> servlet to transfer the content to client using chunked encoding.
> I'm attaching the sample war which can be deployed in tomcat/tomee to
> reproduce the issue. I wrote a sample client program using http client to
> reproduce the issue. Below is the usage of the same.
> Deploy the war in tomcat/tomee.
> run the following commands from zip extracted location.
> The sample files are present in the context root of the web application.
>
> java -jar client.jar
> <a href="http://tomcathost:port/content/content.do?fileName=original.jpg">http://tomcathost:port/content/content.do?fileName=original.jpg
> I'm getting HTTP transfer failed: java.io.IOException: Protocol violation:
> Unexpected single newline character in chunk size error
>
> I tried to save copy of the original file by opening in windows paint and i
> don't see the issue
> java -jar client.jar
>
> http://smunagapf1qh9z7.opentext.net:18080/content/content.do?fileName=edited.jpg
>
> No issue with this file..
> Note : both original and edited files are present in context root and the
> output of the client program is a jpg file whose name will be current time
> in millis.jpg
>
> Please help me to understand the root cause of this issue and what possibly
> in headers of jpg encoding is causing this issue.
> Note : Code compiled with jdk 8 and also transfer is successful for other
> files whose size is very less or huge also ChunkedEncodingIssue.zip
> <
> http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip>
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>


--
Atentamente:
César Hernández.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
The stack trace looks something like below. I'll share the required sources
and exact stack trace in short time:

The link for earlier attachment (binaries only without sources) :
http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip

.
.
.
... 7 common frames omitted
Caused by: java.io.IOException: Protocol violation: Unexpected single
newline character in chunk size
at
org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:273)
~[commons-httpclient-3.1.jar:na]
at
org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
~[commons-httpclient-3.1.jar:na]
at
org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
~[commons-httpclient-3.1.jar:na]
at java.io.FilterInputStream.read(FilterInputStream.java:133)
~[na:1.8.0_141]
at
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
~[commons-httpclient-3.1.jar:na]
at java.io.FilterInputStream.read(FilterInputStream.java:107)
~[na:1.8.0_141]
at
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:127)
~[commons-httpclient-3.1.jar:na]
at java.nio.file.Files.copy(Files.java:2908) ~[na:1.8.0_141]
at java.nio.file.Files.copy(Files.java:3027) ~[na:1.8.0_141]





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

Richard Monson-Haefel
Hi!

Thanks for reporting this.  Is the exception dump from your client
communicating with TomEE?  I'm assuming that what it is, but I want to be
sure.  If exception is generated by a TomEE instance that would be a
different situation.

Richard

On Fri, Nov 8, 2019 at 5:27 AM mshvr <[hidden email]>
wrote:

> The stack trace looks something like below. I'll share the required sources
> and exact stack trace in short time:
>
> The link for earlier attachment (binaries only without sources) :
>
> http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip
>
> .
> .
> .
> ... 7 common frames omitted
> Caused by: java.io.IOException: Protocol violation: Unexpected single
> newline character in chunk size
> at
>
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:273)
> ~[commons-httpclient-3.1.jar:na]
> at
>
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> ~[commons-httpclient-3.1.jar:na]
> at
>
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> ~[commons-httpclient-3.1.jar:na]
> at java.io.FilterInputStream.read(FilterInputStream.java:133)
> ~[na:1.8.0_141]
> at
>
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> ~[commons-httpclient-3.1.jar:na]
> at java.io.FilterInputStream.read(FilterInputStream.java:107)
> ~[na:1.8.0_141]
> at
>
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:127)
> ~[commons-httpclient-3.1.jar:na]
> at java.nio.file.Files.copy(Files.java:2908) ~[na:1.8.0_141]
> at java.nio.file.Files.copy(Files.java:3027) ~[na:1.8.0_141]
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
Didn't get any errors in the tomee server but when the client tried to read
the data from stream, this exception is thrown..
Just to reiterate, this happens for this specific file only and with same
set of libraries and client program i didn't see this exception in other app
server..



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

Richard Monson-Haefel
OK. That narrows it down. Can you share the client source code?

On Wed, Nov 13, 2019 at 12:39 AM mshvr <[hidden email]>
wrote:

> Didn't get any errors in the tomee server but when the client tried to read
> the data from stream, this exception is thrown..
> Just to reiterate, this happens for this specific file only and with same
> set of libraries and client program i didn't see this exception in other
> app
> server..
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
my apologies for the delayed response in sharing the sample program source
code.
I created a git repository with just 2 files, One for client code and the
other for server.
These are source files for the class files shared in the first attachment.
https://github.com/sreeharshamunagala/ChunkedEncoding
Let me know if this is accessible and if anything else helps for
troubleshooting.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

jgallimore
Awesome - that's accessible. Should be a big help - thank you!

On Tue, Nov 26, 2019 at 6:24 AM mshvr <[hidden email]>
wrote:

> my apologies for the delayed response in sharing the sample program source
> code.
> I created a git repository with just 2 files, One for client code and the
> other for server.
> These are source files for the class files shared in the first attachment.
> https://github.com/sreeharshamunagala/ChunkedEncoding
> Let me know if this is accessible and if anything else helps for
> troubleshooting.
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
Hi,Any clue on what is going wrong and the possible root cause?



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html