You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Shriram <sh...@gmail.com> on 2014/06/25 14:33:04 UTC

RE: Outofmemory error in datahandler

I am downloading a file by clicking a link. I am using jdk1.7, cxf-2.7.5 and
enabled MTOM in both client and server. For UI i am using struts1.2. I got
the below exception

[default-workqueue-8] ERROR consoleErrorLog - Exception in thread
"default-workqueue-8" 
[default-workqueue-8] ERROR consoleErrorLog - java.lang.OutOfMemoryError:
Java heap space
[default-workqueue-8] ERROR consoleErrorLog - 

[default-workqueue-6] WARN org.apache.cxf.phase.PhaseInterceptorChain -
Interceptor for
{http://com.java.test.task/}TestService#{http://api.services.test.task/
}getTestFile has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: Pipe closed
    at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:258)
    at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
    at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:114)
    at
org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
    at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
    at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at
org.apache.cxf.transport.local.LocalConduit$1$1.run(LocalConduit.java:143)
    at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[java.io.IOException: Pipe closed]
    at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
    at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
    at
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
    at
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:539)
    at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:233)
    ... 13 more
Caused by: java.io.IOException: Pipe closed
    at
java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:261)
    at java.io.PipedInputStream.receive(PipedInputStream.java:227)
    at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
    at
org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
    at
com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.flushBuffer(UTF8XmlOutput.java:418)
    at
com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.text(UTF8XmlOutput.java:371)
    at
com.sun.xml.bind.v2.runtime.unmarshaller.Base64Data.writeTo(Base64Data.java:313)
    at
com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.text(UTF8XmlOutput.java:312)
    at
com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:356)
    at
com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$PcdataImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:183)
    at
com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
    at
com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:130)
    at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:361)
    at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
    at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156)
    at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
    at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
    at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
    at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
    at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
    at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
    ... 17 more

Serverside code:

DataHandler theDataHandler =    new DataHandler(new FileDataSource(new
File("filename"");
            aResponse.setHeader("Pragma", "dummy");
            aResponse.setHeader("Cache-Control", "private");
            String contentType = "text/plain";
            aResponse.setContentType(contentType);
            aResponse.setHeader("Content-Disposition",
                    "attachment; filename=\"" + name + ".txt\"");

            if (theDataHandler != null)
            {
                downloadFile(inputStream from datahandler, response
OutputStream());
            }

Using Datahandler to handle the download. i am getting null only for larger
files. The exception occurs only for large files. I have commented out
LoggingINInterceptor and LoggingOutInterceptor.

Note: I am using localtransport for publishing service. Please tell me MTOM
feature is applicable to localtransport or not? If it is applicable why the
code is not working ?




--
View this message in context: http://cxf.547215.n5.nabble.com/RE-Outofmemory-error-in-datahandler-tp5745554.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Outofmemory error in datahandler

Posted by Shriram <sh...@gmail.com>.
Dan,
   Can you please tell me how to set inifinte time limit in synchronous
timeout.
 ((ClientImpl) proxy).setSynchronousTimeout(infinite timeout.); 

tr
Shriram



--
View this message in context: http://cxf.547215.n5.nabble.com/RE-Outofmemory-error-in-datahandler-tp5745554p5746843.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Outofmemory error in datahandler

Posted by Shriram <sh...@gmail.com>.
Sorry for the late response Dan.

Can you please how to write a test case so that i can provide you the test
case.

As you mentioned in some other post that by default cxf web services are
asynchronous calls.
Suppose if we are making synchronous calls we need to add the synchronous
timeout.

 ((ClientImpl) proxy).setSynchronousTimeout(3600 * 1000); 

Thanks 
Shriram.




--
View this message in context: http://cxf.547215.n5.nabble.com/RE-Outofmemory-error-in-datahandler-tp5745554p5746592.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Outofmemory error in datahandler

Posted by Daniel Kulp <dk...@apache.org>.
Is there any way you could create a full test case for this?  Maybe attach it to a JIRA or as a github repo?

Thanks!

Dan


On Jun 28, 2014, at 12:27 PM, Shriram <sh...@gmail.com> wrote:

> Thanks Dan
> 
> I've just tried uploading a image of more than 5gb size with local
> transport.
> This is just an example program having server and client in a same file .
> The reason behind this is local transport is within a same jvm. If possible
> can you verify this.
> Also please confirm whether webservice.wsdl file is really needed for this
> local transport or not.
> 
> package com.java.testupload;
> 
> import java.io.File;
> import java.util.HashMap;
> import java.util.Map;
> 
> import javax.activation.DataHandler;
> import javax.activation.DataSource;
> import javax.activation.FileDataSource;
> import javax.xml.ws.Endpoint;
> import javax.xml.ws.soap.SOAPBinding;
> 
> import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
> 
> import com.sun.xml.internal.ws.developer.JAXWSProperties;
> 
> public class ServicePublisher {
> 
> 	private static final String FILENAME = "winserver";
> 	private static final String FILETYPE = "vdi";
> 	private static final String FILEPATH =
> "D:\\Windowsserver_VirtualDrive\\winserver.vdi";
> 
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) {
> 		// Endpoint ep = Endpoint
> 		// .publish(
> 		//
> "http://localhost:8080/TestUploadServer/services/TestUploadServerImplPort",
> 		// new TestUploadServerImpl());
> 		Endpoint ep = Endpoint.publish("local://TestUploadServerImplPort",
> 				new TestUploadServerImpl());
> 		SOAPBinding binding = (SOAPBinding) ep.getBinding();
> 		binding.setMTOMEnabled(true);
> 		
> 		consumeServiceFromClient();
> 	}
> 
> 	private static void consumeServiceFromClient() {
> 		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> 		Map<String, Object> props = new HashMap<String, Object>();
> 		props.put("mtom-enabled", Boolean.TRUE);
> //		props.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
> 		factory.setProperties(props);
> 		factory.setServiceClass(TestUploadServer.class);
> 		factory.setAddress("local://TestUploadServerImplPort");
> 		TestUploadServer uploadWebservice = (TestUploadServer) factory.create();
> 
> 		FileUploader file = new FileUploader();
> 
> 		file.setName(FILENAME);
> 		file.setFileType(FILETYPE);
> 
> 		DataSource source = new FileDataSource(new File(FILEPATH));
> 		file.setDfile(new DataHandler(source));
> 		uploadWebservice.uploadFile(file);
> 		System.out.println("Finished copying....");
> 	}
> }
> 
> Thanks,
> Shriram
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/RE-Outofmemory-error-in-datahandler-tp5745554p5745732.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Outofmemory error in datahandler

Posted by Shriram <sh...@gmail.com>.
Thanks Dan

I've just tried uploading a image of more than 5gb size with local
transport.
This is just an example program having server and client in a same file .
The reason behind this is local transport is within a same jvm. If possible
can you verify this.
Also please confirm whether webservice.wsdl file is really needed for this
local transport or not.

package com.java.testupload;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.xml.ws.Endpoint;
import javax.xml.ws.soap.SOAPBinding;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

import com.sun.xml.internal.ws.developer.JAXWSProperties;

public class ServicePublisher {

	private static final String FILENAME = "winserver";
	private static final String FILETYPE = "vdi";
	private static final String FILEPATH =
"D:\\Windowsserver_VirtualDrive\\winserver.vdi";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Endpoint ep = Endpoint
		// .publish(
		//
"http://localhost:8080/TestUploadServer/services/TestUploadServerImplPort",
		// new TestUploadServerImpl());
		Endpoint ep = Endpoint.publish("local://TestUploadServerImplPort",
				new TestUploadServerImpl());
		SOAPBinding binding = (SOAPBinding) ep.getBinding();
		binding.setMTOMEnabled(true);
		
		consumeServiceFromClient();
	}

	private static void consumeServiceFromClient() {
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
		Map<String, Object> props = new HashMap<String, Object>();
		props.put("mtom-enabled", Boolean.TRUE);
//		props.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
		factory.setProperties(props);
		factory.setServiceClass(TestUploadServer.class);
		factory.setAddress("local://TestUploadServerImplPort");
		TestUploadServer uploadWebservice = (TestUploadServer) factory.create();

		FileUploader file = new FileUploader();

		file.setName(FILENAME);
		file.setFileType(FILETYPE);

		DataSource source = new FileDataSource(new File(FILEPATH));
		file.setDfile(new DataHandler(source));
		uploadWebservice.uploadFile(file);
		System.out.println("Finished copying....");
	}
}

Thanks,
Shriram



--
View this message in context: http://cxf.547215.n5.nabble.com/RE-Outofmemory-error-in-datahandler-tp5745554p5745732.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Outofmemory error in datahandler

Posted by Daniel Kulp <dk...@apache.org>.
I’m not sure if anyone has ever tried MTOM with the Local transport.  In theory, it should work.  Not sure why it isn’t.   If you could create a small test case that shows the error, that would be interesting to look at.

Dan


On Jun 25, 2014, at 8:33 AM, Shriram <sh...@gmail.com> wrote:

> I am downloading a file by clicking a link. I am using jdk1.7, cxf-2.7.5 and
> enabled MTOM in both client and server. For UI i am using struts1.2. I got
> the below exception
> 
> [default-workqueue-8] ERROR consoleErrorLog - Exception in thread
> "default-workqueue-8" 
> [default-workqueue-8] ERROR consoleErrorLog - java.lang.OutOfMemoryError:
> Java heap space
> [default-workqueue-8] ERROR consoleErrorLog - 
> 
> [default-workqueue-6] WARN org.apache.cxf.phase.PhaseInterceptorChain -
> Interceptor for
> {http://com.java.test.task/}TestService#{http://api.services.test.task/
> }getTestFile has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Marshalling Error: Pipe closed
>    at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:258)
>    at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
>    at
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:114)
>    at
> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
>    at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>    at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
>    at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>    at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>    at
> org.apache.cxf.transport.local.LocalConduit$1$1.run(LocalConduit.java:143)
>    at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
>    at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>    at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>    at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
>    at java.lang.Thread.run(Thread.java:722)
> Caused by: javax.xml.bind.MarshalException
> - with linked exception:
> [java.io.IOException: Pipe closed]
>    at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
>    at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
>    at
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
>    at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:539)
>    at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:233)
>    ... 13 more
> Caused by: java.io.IOException: Pipe closed
>    at
> java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:261)
>    at java.io.PipedInputStream.receive(PipedInputStream.java:227)
>    at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
>    at
> org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
>    at
> com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.flushBuffer(UTF8XmlOutput.java:418)
>    at
> com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.text(UTF8XmlOutput.java:371)
>    at
> com.sun.xml.bind.v2.runtime.unmarshaller.Base64Data.writeTo(Base64Data.java:313)
>    at
> com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.text(UTF8XmlOutput.java:312)
>    at
> com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:356)
>    at
> com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$PcdataImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:183)
>    at
> com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
>    at
> com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:130)
>    at
> com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:361)
>    at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
>    at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156)
>    at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
>    at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
>    at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
>    at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
>    at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
>    at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
>    ... 17 more
> 
> Serverside code:
> 
> DataHandler theDataHandler =    new DataHandler(new FileDataSource(new
> File("filename"");
>            aResponse.setHeader("Pragma", "dummy");
>            aResponse.setHeader("Cache-Control", "private");
>            String contentType = "text/plain";
>            aResponse.setContentType(contentType);
>            aResponse.setHeader("Content-Disposition",
>                    "attachment; filename=\"" + name + ".txt\"");
> 
>            if (theDataHandler != null)
>            {
>                downloadFile(inputStream from datahandler, response
> OutputStream());
>            }
> 
> Using Datahandler to handle the download. i am getting null only for larger
> files. The exception occurs only for large files. I have commented out
> LoggingINInterceptor and LoggingOutInterceptor.
> 
> Note: I am using localtransport for publishing service. Please tell me MTOM
> feature is applicable to localtransport or not? If it is applicable why the
> code is not working ?
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/RE-Outofmemory-error-in-datahandler-tp5745554.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com