[ 
https://issues.apache.org/jira/browse/AXIS2-5304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13443169#comment-13443169
 ] 

AndyB commented on AXIS2-5304:
------------------------------

Hi, in our case the problem was found on the server side. I'm on the client 
side and not familiar with the solution details, but after some investigations 
they told me that they closed the sending stream to early. Now it is fixed and 
everything is fine. So my recommendation is to take also the 
server-side-service implementation into account for further analysis.
                
> Attempted read on closed stream
> -------------------------------
>
>                 Key: AXIS2-5304
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5304
>             Project: Axis2
>          Issue Type: Bug
>          Components: client-api
>    Affects Versions: 1.6.1, 1.6.2
>         Environment: Windows XP SP2, JDK 1.6, AXIS2-1.6.2, Jboss 4.0
>            Reporter: Sridhar Ratna
>            Priority: Blocker
>              Labels: axiom_1.2.12, axiom_1.2.13, axis2_1.6.1, axis2_1.6.2, 
> webservice_download_client
>         Attachments: SampleServiceClient.zip, SampleService.zip
>
>
> When trying to download the large binary file getting the exception 
> "org.apache.axiom.om.OMException: java.io.IOException: Attempted read on 
> closed stream."
> Have the following properties in axis2.xml
>     <parameter name="enableMTOM">true</parameter>
>     <parameter name="enableSwA">false</parameter>
> WSDL is
> ========
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>       xmlns:ns1="http://org.apache.axis2/xsd"; 
> xmlns:ns="http://sample.com/sample/SampleService";
>       xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"; 
> xmlns:http="http://schemas.xmlsoap.org/wsdl/http/";
>       xmlns:ax21="http://sample.com/sample/SampleService/xsd"; 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
>       xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"; 
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
>       xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"; 
> targetNamespace="http://sample.com/sample/SampleService";>
>       <wsdl:documentation>
>               Please Type your service description here
>       </wsdl:documentation>
>       <wsdl:types>
>         <xs:schema elementFormDefault="qualified" 
> targetNamespace="http://sample.com/sample/SampleService";>
>               
>                       <xs:complexType name="SampleRequestType">
>                               <xs:sequence>
>                                       <xs:element name="fileName" 
> type="xs:string" minOccurs="1" maxOccurs="1"/>
>                                       <xs:element name="contentType" 
> type="xs:string" minOccurs="0" maxOccurs="1"/>
>                               </xs:sequence>
>                       </xs:complexType>
>               <xs:complexType name="SampleResponseType">
>               <xs:sequence>
>                       <xs:element name="fileName" type="xs:string" 
> minOccurs="1" maxOccurs="1" />
>                     <xs:element name="content" type="xs:base64Binary" 
> minOccurs="0" maxOccurs="1" />
>                               </xs:sequence>
>             </xs:complexType>
>               
>                       <xs:element name="SampleRequest" 
> type="ns:SampleRequestType" />
>                       <xs:element name="SampleResponse" 
> type="ns:SampleResponseType" />
>         </xs:schema>
>     </wsdl:types>
>       <wsdl:message name="SampleRequest">
>               <wsdl:part name="parameters" element="ns:SampleRequest" />
>       </wsdl:message>
>       <wsdl:message name="SampleResponse">
>               <wsdl:part name="parameters" element="ns:SampleResponse" />
>       </wsdl:message>
>       <wsdl:portType name="SampleServicePortType">
>               <wsdl:operation name="SampleRequest">
>                       <wsdl:input message="ns:SampleRequest" 
> wsaw:Action="urn:SampleRequest" />
>                       <wsdl:output message="ns:SampleResponse" 
> wsaw:Action="urn:SampleResponse" />
>               </wsdl:operation>
>       </wsdl:portType>
>       <wsdl:binding name="SampleServiceSoap11Binding" 
> type="ns:SampleServicePortType">
>               <soap:binding transport="http://schemas.xmlsoap.org/soap/http";
>                       style="document" />
>               <wsdl:operation name="SampleRequest">
>                       <soap:operation soapAction="urn:SampleRequest" 
> style="document" />
>                       <wsdl:input>
>                               <soap:body use="literal" />
>                       </wsdl:input>
>                       <wsdl:output>
>                               <soap:body use="literal" />
>                       </wsdl:output>
>               </wsdl:operation>
>       </wsdl:binding>
>       <wsdl:binding name="SampleServiceSoap12Binding" 
> type="ns:SampleServicePortType">
>               <soap12:binding 
> transport="http://schemas.xmlsoap.org/soap/http"; style="document" />
>               <wsdl:operation name="SampleRequest">
>                       <soap12:operation soapAction="urn:SampleRequest" 
> style="document" />
>                       <wsdl:input>
>                               <soap12:body use="literal" />
>                       </wsdl:input>
>                       <wsdl:output>
>                               <soap12:body use="literal" />
>                       </wsdl:output>
>               </wsdl:operation>
>       </wsdl:binding>
>       <wsdl:binding name="SampleServiceHttpBinding" 
> type="ns:SampleServicePortType">
>               <http:binding verb="POST" />
>               <wsdl:operation name="SampleRequest">
>                       <http:operation location="SampleRequest" />
>                       <wsdl:input>
>                               <mime:content type="text/xml" part="parameters" 
> />
>                       </wsdl:input>
>                       <wsdl:output>
>                               <mime:content type="text/xml" part="parameters" 
> />
>                       </wsdl:output>
>               </wsdl:operation>
>       </wsdl:binding>
>       <wsdl:service name="SampleService">
>               <wsdl:port name="SampleServiceHttpSoap11Endpoint" 
> binding="ns:SampleServiceSoap11Binding">
>                       <soap:address
>                               
> location="http://localhost:8080/SampleService/services/SampleService.SampleServiceHttpSoap11Endpoint/";
>  />
>               </wsdl:port>
>               <wsdl:port name="SampleServiceHttpSoap12Endpoint" 
> binding="ns:SampleServiceSoap12Binding">
>                       <soap12:address
>                               
> location="http://localhost:8080/SampleService/services/SampleService.SampleServiceHttpSoap12Endpoint/";
>  />
>               </wsdl:port>
>               <wsdl:port name="SampleServiceHttpEndpoint" 
> binding="ns:SampleServiceHttpBinding">
>                       <http:address
>                               
> location="http://localhost:8080/SampleService/services/SampleService.SampleServiceHttpEndpoint/";
>  />
>               </wsdl:port>
>       </wsdl:service>
> </wsdl:definitions>
> Service class
> ============
> public SampleResponse sampleRequest(SampleRequest req) {
> try {
>       SampleResponse response = new SampleResponse();
>       SampleResponseType type = new SampleResponseType();
>       FileInputStream fis = new 
> FileInputStream("c:/tmp/"+req.getSampleRequest().getFileName());
>       DataHandler dh = new DataHandler(new StreamDataSource(fis, 
> req.getSampleRequest().getContentType()));
>       type.setContent(dh);
>       type.setFileName(req.getSampleRequest().getFileName());
>       response.setSampleResponse(type);
>       return response;
> } catch (Exception e) {
> e.printStackTrace();
> }
> return null;
> }
> client code is 
> public static void main(String[] args) throws Exception{
>               
> EndpointReference epr = new 
> EndpointReference("http://localhost:8080/SampleService/services/SampleService.SampleServiceHttpSoap12Endpoint/";);
>       ServiceClient sc = new ServiceClient();
>       sc.setTargetEPR(epr);
>               
>       SampleRequestType type = new SampleRequestType();
>       type.setFileName("server.log");
>       type.setContentType("text/plain");
>       SampleRequest request = new SampleRequest();
>       request.setSampleRequest(type);
>       OMElement ele = 
> sc.sendReceive(request.getOMElement(SampleRequest.MY_QNAME, 
> OMAbstractFactory.getOMFactory()));
>               
>       Options options = new Options();
>                 options.setTo(epr);
>                 options.setAction("getDocumentRequest");
>                 options.setProperty(Constants.Configuration.ENABLE_MTOM, 
> Constants.VALUE_TRUE);
>                 
> options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS,Constants.VALUE_TRUE);
>  
>                 
> options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,"c:/tmmp"); 
>                 
> options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, 
> "4000000000"); 
>         
>                sc.setOptions(options);
>               OMElement element = sc.sendReceive(ele);
> }
> Error trace is
> Exception in thread "main" org.apache.axiom.om.OMException: 
> java.io.IOException: Attempted read on closed stream.
>       at 
> org.apache.axiom.om.impl.MTOMXMLStreamWriter.flush(MTOMXMLStreamWriter.java:259)
>       at 
> org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:190)
>       at 
> org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
>       at 
> org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
>       at 
> org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
>       at 
> org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
>       at 
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
>       at 
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
>       at 
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
>       at 
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
>       at 
> org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
>       at 
> org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
>       at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
>       at 
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
>       at 
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
>       at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
>       at 
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
>       at 
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
>       at 
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
>       at 
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
>       at 
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
>       at com.sample.sampleservice.client.Client.main(Client.java:71)
> Caused by: java.io.IOException: Attempted read on closed stream.
>       at 
> org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
>       at 
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107)
>       at java.io.FilterInputStream.read(FilterInputStream.java:111)
>       at 
> org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:147)
>       at 
> org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:111)
>       at 
> org.apache.james.mime4j.io.MimeBoundaryInputStream.fillBuffer(MimeBoundaryInputStream.java:223)
>       at 
> org.apache.james.mime4j.io.MimeBoundaryInputStream.read(MimeBoundaryInputStream.java:157)
>       at 
> org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:111)
>       at 
> org.apache.james.mime4j.io.BufferedLineReaderInputStream.read(BufferedLineReaderInputStream.java:158)
>       at 
> org.apache.james.mime4j.io.LineReaderInputStreamAdaptor.read(LineReaderInputStreamAdaptor.java:67)
>       at java.io.FilterInputStream.read(FilterInputStream.java:111)
>       at 
> org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:147)
>       at java.io.FilterInputStream.read(FilterInputStream.java:90)
>       at 
> org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:159)
>       at 
> org.apache.axiom.attachments.impl.BufferUtils.inputStream2OutputStream(BufferUtils.java:84)
>       at 
> org.apache.axiom.om.impl.MTOMXMLStreamWriter.flush(MTOMXMLStreamWriter.java:248)
>       ... 21 more
> now changed the client code to the following
> SampleServiceStub stub = new SampleServiceStub();
> stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
>  Constants.VALUE_TRUE);
> stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(1000*60*10 );
> stub._getServiceClient().getOptions().setProperty(Constants.Configuration.CACHE_ATTACHMENTS,
>  Constants.VALUE_TRUE);
> stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,
>  "c:/tmp");
> stub._getServiceClient().getOptions().setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD,
>  "400000");
>       
> SampleRequestType type = new SampleRequestType();
> type.setFileName("server.log");
> type.setContentType("text/plain");
>                       
> SampleRequest request = new SampleRequest();
> request.setSampleRequest(type);
>                       
> SampleResponse response = stub.sampleRequest(request);
> InputStream in = response.getSampleResponse().getContent().getInputStream();
> This time got the following
> org.apache.axiom.om.OMException: org.apache.axiom.ext.io.StreamCopyException: 
> Error reading from source
>       at 
> org.apache.axiom.attachments.PartContentFactory.createPartContent(PartContentFactory.java:153)
>       at org.apache.axiom.attachments.PartImpl.fetch(PartImpl.java:176)
>       at org.apache.axiom.attachments.PartImpl.getContent(PartImpl.java:149)
>       at 
> org.apache.axiom.attachments.PartImpl.getInputStream(PartImpl.java:224)
>       at 
> org.apache.axiom.attachments.PartDataSource.getInputStream(PartDataSource.java:44)
>       at javax.activation.DataHandler.getInputStream(DataHandler.java:237)
>       at com.sample.sampleservice.client.Client.main(Client.java:109)
> Caused by: org.apache.axiom.ext.io.StreamCopyException: Error reading from 
> source
>       at 
> org.apache.axiom.attachments.utils.BAAOutputStream.readFrom(BAAOutputStream.java:114)
>       at 
> org.apache.axiom.attachments.impl.BufferUtils.inputStream2OutputStream(BufferUtils.java:107)
>       at 
> org.apache.axiom.attachments.PartContentFactory.createPartContent(PartContentFactory.java:125)
>       ... 6 more
> Caused by: java.io.IOException: Attempted read on closed stream.
>       at 
> org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
>       at 
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107)
>       at java.io.FilterInputStream.read(FilterInputStream.java:111)
>       at 
> org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:147)
>       at 
> org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:111)
>       at 
> org.apache.james.mime4j.io.MimeBoundaryInputStream.fillBuffer(MimeBoundaryInputStream.java:223)
>       at 
> org.apache.james.mime4j.io.MimeBoundaryInputStream.read(MimeBoundaryInputStream.java:157)
>       at 
> org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:111)
>       at 
> org.apache.james.mime4j.io.BufferedLineReaderInputStream.read(BufferedLineReaderInputStream.java:158)
>       at 
> org.apache.james.mime4j.io.LineReaderInputStreamAdaptor.read(LineReaderInputStreamAdaptor.java:67)
>       at 
> org.apache.axiom.attachments.utils.BAAOutputStream.readFrom(BAAOutputStream.java:112)
>       ... 8 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to