0

我正在通过单击链接下载文件。我正在使用 jdk1.7、cxf-2.7.5 并在客户端和服务器中都启用了 MTOM。对于 UI,我使用的是 struts1.2。我得到了以下异常

[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

服务器端代码:

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());
            }

使用 Datahandler 处理下载。我只为较大的文件获得空值。该异常仅发生在大文件中。我已经注释掉了 LoggingINInterceptor 和 LoggingOutInterceptor。

我正在使用 localtransport 进行发布服务。请告诉我 MTOM 功能是否适用于本地传输?如果适用,为什么代码不起作用?

4

1 回答 1

0

检查您的导入。可能是您正在导入 com.sun.xml.internal.ws.developer.JAXWSProperties 而不是 com.sun.xml.ws.developer.JAXWSProperties。或者您可以尝试在服务器中禁用 HttpTransportPipe.dump。

于 2014-06-25T14:04:10.413 回答