have you actaully checked your heap space?

-Xmx does not specify which pool the memory goes to, you're going to
need more parameters than that.

keep in mind 750mb is just the object once in memory, when you create
the soap message it may duplicate the bytes, and if it does a
base4encoding on it, it may tripple in size so you might need to
ensure your smallest memory pool is close to 3g or 4g... given it
splits the memory pools into different parts, I'm not convinced your
-Xmx6g is enough...

I must say 750mb soap payload is quite impressively large.

On 6/19/13, shamikb <[email protected]> wrote:
> Hi,
>
>  I'm struggling to read a large file transmitted through a SOAP based web
> service. The client code is failing with Out of memory exception. I'm using
> MTOM to send the binary data, hoping that would be able to take care of
> transmitting and reading large file. The file size in question is 750mb.
> I'm
> using apache cxf. Here's the web services endpoint implementation.
>
> @MTOM
> @WebService(endpointInterface =
> "com.test.contentservice.service.IContentService")
> @BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
> public class ContentServiceImpl implements IContentService {
>
> @Override
>     public ContentResponse getFile(ContentRequest req) {
>         ContentResponse res = new ContentResponse();
>         try {
>             File file = this.contentManager.getFile(req);
>             DataSource source = new FileDataSource(file);
>             DataHandler dataHandler = new DataHandler(source);
>             res.setFileData(dataHandler);
>             res.setFileName(file.getName());
>         } catch (Exception ex) {
>         }
>         return res;
>     }
>
>
> I've turned on MTOM through spring , Spring entry :
>
> <jaxws:endpoint id="contentService" implementor="#contentServiceImpl"
>         address="/contentservice">
>         <jaxws:dataBinding>
>             <bean class="org.apache.cxf.jaxb.JAXBDataBinding">
>                 <property name="marshallerProperties">
>                     <map>
>                         <entry>
>                             <key>
>                                 <value>jaxb.encoding</value>
>                             </key>
>                             <value>UTF-8</value>
>                         </entry>
>                     </map>
>                 </property>
>             </bean>
>         </jaxws:dataBinding>
>         <jaxws:properties>
>             <entry key="mtom-enabled" value="true" />
>         </jaxws:properties>
>     </jaxws:endpoint>
>
> The client code is generated using cxf wsdl2java tool. Here's a sample
> client code
>
> ContentResponse res =  new ContentResponse();
>         try{
>             res = getRegisterPort().getFile(req);
>             DataHandler dataHandler = res.getFileData();
>             if(dataHandler!=null){
>                     final InputStream in = dataHandler.getInputStream();
>                     byte[] bytes = IOUtils.toByteArray(in);
>             }
>         }catch (Exception ex) {
>             LOGGER.error("Error in invoking getContent service",ex);
>         }
>
> Here's the response object
>
> @XmlAccessorType( XmlAccessType.FIELD )
> public class ContentResponse extends ContentServiceResponseBase {
>
>     private String content;
>     private String source;
>     private String fileName;
>     @XmlMimeType("application/octet-stream")
>     private DataHandler fileData;
> // Getter / Setter ...
> }
>
> Turned on mtom in client code :
>
> final BindingProvider bpAdmin = (BindingProvider) port;
>               
> bpAdmin.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> curlUrl);
>               SOAPBinding binding = (SOAPBinding)bpAdmin.getBinding();
>               binding.setMTOMEnabled(true);
>
>
> jvm entry is as follows :
>
> -Xms64m -Xmx6144m
>
> And the exception :
>
> Exception in thread "taskExecutor-12" java.lang.OutOfMemoryError: Java heap
> space
>        at java.util.Arrays.copyOf(Arrays.java:2882)
>        at
> java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
>        at
> java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:515)
>        at java.lang.StringBuilder.append(StringBuilder.java:189)
>        at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleCharacters(StAXStreamConnector.java:312)
>        at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
>        at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:349)
>        at
> com.sun.xml.internal.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:109)
>        at com.sun.xml.internal.bind.api.Bridge.unmarshal(Bridge.java:222)
>        at
> com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:514)
>        at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:110)
>        at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
>        at
> com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
>        at $Proxy33.getFile(Unknown Source)
>
>
> Not sure what I'm missing here, any pointer will be highly appreciated.
>
> - Thanks
>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Out-of-memory-exception-while-retrieving-large-file-using-CXF-SOAP-webservice-tp5729463.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Ted.

Reply via email to