You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by ggarciao <gu...@ggarciao.com> on 2012/06/14 10:04:16 UTC

java.lang.OutOfMemoryError in a MTOM client

I'm creating a webservice client to send huge files using MTOM. The server
side (CXF) is implemented correctly: MTOM is enabled and is using
DataHandler instead of byte[]. I tested the server side with not-that-big
files and is working as expected: the client is sending and XOP attachment
and the server side is getting a well formed DataHandler that allows read
the file and put it in th file system (or database) whiout loading all in
memory.


Everything seems to be working, but when I try to send huge files (23 GB) I
get a /java.lang.OutOfMemoryError/ in the client side (and no logs in the
server side). This is the client side implementation:



*
DataServiceService dataServiceService = new DataServiceService(new
URL(serviceURI + "?wsdl"), new QName(endpointNamespace, endpointName));
DataService dataService = dataServiceService.getPort(DataService.class);


BindingProvider bindingProvider = (BindingProvider) dataService;
Map<String, Object> requestContext = bindingProvider.getRequestContext();
requestContext.put(BindingProvider.USERNAME_PROPERTY, user);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
((SOAPBinding) bindingProvider.getBinding()).setMTOMEnabled(true);

// Preparing the request

dataService.update(objects, true); // service call*


When the service is called, I got:
*Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:2786)
	at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
	at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:61)
	at javax.activation.DataHandler.writeTo(DataHandler.java:294)
	at
com.sun.xml.internal.ws.encoding.MtomCodec$ByteArrayBuffer.write(MtomCodec.java:189)
	at com.sun.xml.internal.ws.encoding.MtomCodec.encode(MtomCodec.java:156)
	at
com.sun.xml.internal.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:249)
	at
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:144)
	at
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
	at
com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
	at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
	at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
	at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
	at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
	at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
	at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
	at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
	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 $Proxy38.update(Unknown Source)*


This stack trace bugs me: We see that the client is using MTOM
/(MtomCodec.encode(MtomCodec.java:156)/ but this codec is using a
/ByteArrayOutputStream/ ???

Can some here help to understand this? and obviously ... if you know how to
solve this pleeeese let me know!

--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-OutOfMemoryError-in-a-MTOM-client-tp5709736.html
Sent from the cxf-issues mailing list archive at Nabble.com.

Re: java.lang.OutOfMemoryError in a MTOM client

Posted by Daniel Kulp <dk...@apache.org>.
You aren't using CXF on the client side:

com.sun.xml.internal.ws.api.....

that's the JAX-WS implementation built into the JDK which doesn't support 
the same level of streaming that CXF does.   Make sure the CXF jars are 
available on the classpath.

Dan




On Thursday, June 14, 2012 01:04:16 AM ggarciao wrote:
> I'm creating a webservice client to send huge files using MTOM. The server
> side (CXF) is implemented correctly: MTOM is enabled and is using
> DataHandler instead of byte[]. I tested the server side with not-that-big
> files and is working as expected: the client is sending and XOP
> attachment and the server side is getting a well formed DataHandler that
> allows read the file and put it in th file system (or database) whiout
> loading all in memory.
> 
> 
> Everything seems to be working, but when I try to send huge files (23 GB)
> I get a /java.lang.OutOfMemoryError/ in the client side (and no logs in
> the server side). This is the client side implementation:
> 
> 
> 
> *
> DataServiceService dataServiceService = new DataServiceService(new
> URL(serviceURI + "?wsdl"), new QName(endpointNamespace, endpointName));
> DataService dataService = dataServiceService.getPort(DataService.class);
> 
> 
> BindingProvider bindingProvider = (BindingProvider) dataService;
> Map<String, Object> requestContext = bindingProvider.getRequestContext();
> requestContext.put(BindingProvider.USERNAME_PROPERTY, user);
> requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
> ((SOAPBinding) bindingProvider.getBinding()).setMTOMEnabled(true);
> 
> // Preparing the request
> 
> dataService.update(objects, true); // service call*
> 
> 
> When the service is called, I got:
> *Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
> 	at java.util.Arrays.copyOf(Arrays.java:2786)
> 	at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
> 	at 
sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:61)
> 	at javax.activation.DataHandler.writeTo(DataHandler.java:294)
> 	at
> com.sun.xml.internal.ws.encoding.MtomCodec$ByteArrayBuffer.write(MtomCodec
> .java:189) at
> com.sun.xml.internal.ws.encoding.MtomCodec.encode(MtomCodec.java:156) at
> com.sun.xml.internal.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.
> java:249) at
> com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Ht
> tpTransportPipe.java:144) at
> com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processReq
> uest(HttpTransportPipe.java:83) at
> com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Def
> erredTransportPipe.java:105) at
> com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587) at
> com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546) at
> com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531) at
> com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428) at
> com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
> 	at 
com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
> at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHand
> ler.java:98) at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHand
> ler.java:78) at
> com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107) at
> $Proxy38.update(Unknown Source)*
> 
> 
> This stack trace bugs me: We see that the client is using MTOM
> /(MtomCodec.encode(MtomCodec.java:156)/ but this codec is using a
> /ByteArrayOutputStream/ ???
> 
> Can some here help to understand this? and obviously ... if you know how
> to solve this pleeeese let me know!
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/java-lang-OutOfMemoryError-in-a-MTOM-clie
> nt-tp5709736.html Sent from the cxf-issues mailing list archive at
> Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: java.lang.OutOfMemoryError in a MTOM client

Posted by ggarciao <gu...@ggarciao.com>.
I forgot to mention that I'm using a /FileDataSource/ to create the
/DataHandler /that I'm sending from the client:


*FieldType data = new FieldType();
data.setName("data");
FileDataSource fileDataSource = new FileDataSource(file);
fileDataSource.setFileTypeMap(new MimetypesFileTypeMap());
data.setData(new DataHandler(fileDataSource));*


Thx in advance ...


--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-OutOfMemoryError-in-a-MTOM-client-tp5709736p5709737.html
Sent from the cxf-issues mailing list archive at Nabble.com.