Computing Magazine

Jersey Rest Service : Stream Already Closed Error

Posted on the 13 September 2013 by Abhishek Somani @somaniabhi
Creating File Upload functionality in WebServices using Jersey is very simple , you can go through this post to create file upload functionality in Jersey Rest Service. However , you may get an exception like this , if you are using Buffered Reader to read the uploaded file stream.
 java.lang.IllegalStateException: Stream already closed
 at org.jvnet.mimepull.DataHead$ReadMultiStream.fetch(DataHead.java:237)
 at org.jvnet.mimepull.DataHead$ReadMultiStream.read(DataHead.java:212)
 at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
 at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
 at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
 at java.io.InputStreamReader.read(InputStreamReader.java:184)
 at java.io.BufferedReader.fill(BufferedReader.java:154)
 at java.io.BufferedReader.readLine(BufferedReader.java:317)
 at java.io.BufferedReader.readLine(BufferedReader.java:382)

This is a known issue in mimepull version 1.6 , which we are using along with jersey multi part jar . Try using mimepull version 1.9 and you will not see this error any more . Post Comments and Suggestions !! Jersey Rest Service : Stream Already Closed Error

Back to Featured Articles on Logo Paperblog