Ok Dan,
I was making some mass in my project, sorry for the alert, doublechecking
was the solution :-)
Now streaming works perfectly on Jboss in the conditions you described.
On WLS we still have some problem due to the fact that Weblogic uses its own
stax implementation.
org.apache.cxf.interceptor.Fault: Marshalling Error: The uri may not be
theempty string.
at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:161)
...
Caused by: java.lang.IllegalArgumentException: The uri may not be theempty
string.
at
weblogic.xml.stax.util.NamespaceContextImpl.getPrefix(NamespaceContextImpl.java:76)
...
We only uses ear to deploy, so
<prefer-web-inf-classes>true</prefer-web-inf-classes>
in our weblogic.xml it isn't enough. But we have to use a filtering
classloader.
We still have some problem to tune it correctly, I'll update the post when
we'll manage it.
Thanks for your support,
Bye,
Marco
dkulp wrote:
>
>
> I think you are still picking up an older version of CXF from someplace.
> The
> stack trace you have below is impossible with the newer code.
>
>> at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:75)
>> at
>> org.apache.cxf.attachment.AttachmentDataSource.<init>(AttachmentDataSource.
>>java:39) at
>
> That's older code. Neither of the constructors of AttachmentDataSource
> call
> IOUtils anymore. Line 39 is just:
> this.ct = ctParam;
>
> I'd double check your libs.
>
> Dan
>
>
>
> On Thu July 30 2009 4:48:40 am dp-isp wrote:
>> I tried the 2.2.3 release candidate as you suggested with the same
>> implementation of my first post, but nothing changes. I also explicitly
>> disabled schema-validation inside cxf.xml of the service (even if it
>> should
>> be the default if I well understood.)
>> Is there a subversion URL or something similar, where I can get diffs
>> between version?
>>
>>
>> This is the thread dump on JBoss where the servlet (WS client) is
>> deployed
>> on. In that moment this thread is actually downloading the file from the
>> WS
>> server a caching it in /tmp/cxf-tmp-960634/cos44564tmp:
>>
>> "http-dev-jboss3-dspstd.csi.it%2F10.102.40.71-13610-1" daemon prio=1
>> tid=0x0837c568 nid=0x2bcc runnable [0x7ec8c000..0x7ec8dda0]
>> at java.net.SocketInputStream.socketRead0(Native Method)
>> at java.net.SocketInputStream.read(SocketInputStream.java:129)
>> at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
>> at
>> java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
>> at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
>> - locked <0xaabfa010> (a java.io.BufferedInputStream)
>> at
>> sun.net.www.http.ChunkedInputStream.fastRead(ChunkedInputStream.java:221)
>> at
>> sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:662)
>> - locked <0xaabfc9c8> (a sun.net.www.http.ChunkedInputStream)
>> at java.io.FilterInputStream.read(FilterInputStream.java:111)
>> at
>> sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLCon
>>nection.java:2172) at
>> java.io.FilterInputStream.read(FilterInputStream.java:111) at
>> java.io.PushbackInputStream.read(PushbackInputStream.java:161) at
>> org.apache.cxf.attachment.MimeBodyPartInputStream.read(MimeBodyPartInputStr
>>eam.java:74) at java.io.InputStream.read(InputStream.java:89)
>> at
>> org.apache.cxf.attachment.DelegatingInputStream.read(DelegatingInputStream.
>>java:77) at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:112)
>> at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:75)
>> at
>> org.apache.cxf.attachment.AttachmentDataSource.<init>(AttachmentDataSource.
>>java:39) at
>> org.apache.cxf.attachment.AttachmentUtil.createAttachment(AttachmentUtil.ja
>>va:168) at
>> org.apache.cxf.attachment.AttachmentDeserializer.createAttachment(Attachmen
>>tDeserializer.java:283) at
>> org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeseria
>>lizer.java:194) at
>> org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachment
>>Collection.java:73) at
>> org.apache.cxf.attachment.LazyDataSource.load(LazyDataSource.java:49)
>> - locked <0xaac08660> (a
>> org.apache.cxf.attachment.LazyDataSource)
>> at
>> org.apache.cxf.attachment.LazyDataSource.getContentType(LazyDataSource.java
>>:59) at javax.activation.DataHandler.<init>(DataHandler.java:44) at
>> org.apache.cxf.jaxb.attachment.JAXBAttachmentUnmarshaller.getAttachmentAsDa
>>taHandler(JAXBAttachmentUnmarshaller.java:55) at
>> com.sun.xml.bind.v2.runtime.unmarshaller.MTOMDecorator.startElement(MTOMDec
>>orator.java:96) at
>> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartEle
>>ment(StAXStreamConnector.java:275) at
>> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStr
>>eamConnector.java:209) at
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unmars
>>hallerImpl.java:360) at
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unmarsh
>>allerImpl.java:339) at
>> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:6
>>07) at
>> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:5
>>27) at
>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:114)
>> at
>> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral
>>InInterceptor.java:99) at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>>n.java:236) - locked <0xaabffa20> (a
>> org.apache.cxf.phase.PhaseInterceptorChain) at
>> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:645) at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
>>eInternal(HTTPConduit.java:2132) at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons
>>e(HTTPConduit.java:2015) at
>> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
>>duit.java:1940) at
>> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
>> at
>> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:627)
>> at
>> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte
>>rceptor.handleMessage(MessageSenderInterceptor.java:62) at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>>n.java:236) - locked <0xaabda040> (a
>> org.apache.cxf.phase.PhaseInterceptorChain) at
>> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:471) at
>> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:301) at
>> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:253) at
>> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
>> at
>> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:121)
>> at $Proxy338.downloadMethod(Unknown Source)
>> at
>> it.csi.mtomsample.streamingclient.presentation.wsclient.DownloadServletBrow
>>ser.doPost(Unknown Source)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>>nFilterChain.java:290) at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>>hain.java:206) at
>> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.j
>>ava:96) at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>>nFilterChain.java:235) at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>>hain.java:206) at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j
>>ava:230) at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j
>>ava:175) at
>> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoc
>>iationValve.java:179) at
>> org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java
>>:84) at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:12
>>8) at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10
>>4) at
>> org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnect
>>ionValve.java:157) at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav
>>a:109) at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
>> at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>> at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Htt
>>p11Protocol.java:580) at
>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>> at java.lang.Thread.run(Thread.java:595)
>>
>>
>>
>> This is the thread dump on WebLogic where the WS service is deployed on.
>> In
>> that moment this thread is actually providing the file to the client.
>>
>>
>> "[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default
>> (self-tuning)'" id=17 idx=0x5c tid=17758 prio=5 alive, in native, daemon
>> at
>> jrockit/net/SocketNativeIO.writeBytesPinned(Ljava/io/FileDescriptor;[BII)V(
>>Native Method)
>> at jrockit/net/SocketNativeIO.socketWrite(SocketNativeIO.java:45)
>> at
>> java/net/SocketOutputStream.socketWrite0(Ljava/io/FileDescriptor;[BII)V(Soc
>>ketOutputStream.java) at
>> java/net/SocketOutputStream.socketWrite(SocketOutputStream.java:92) at
>> java/net/SocketOutputStream.write(SocketOutputStream.java:136) at
>> weblogic/servlet/internal/ChunkOutput.writeChunkTransfer(ChunkOutput.java:5
>>25) at
>> weblogic/servlet/internal/ChunkOutput.writeChunks(ChunkOutput.java:504)
>> at weblogic/servlet/internal/ChunkOutput.flush(ChunkOutput.java:382)
>> at
>> weblogic/servlet/internal/CharsetChunkOutput.flush(CharsetChunkOutput.java:
>>249) at
>> weblogic/servlet/internal/ChunkOutput.checkForFlush(ChunkOutput.java:469)
>> at
>> weblogic/servlet/internal/CharsetChunkOutput.implWrite(CharsetChunkOutput.j
>>ava:396) at
>> weblogic/servlet/internal/CharsetChunkOutput.write(CharsetChunkOutput.java:
>>198) at
>> weblogic/servlet/internal/ChunkOutputWrapper.write(ChunkOutputWrapper.java:
>>133) at
>> weblogic/servlet/internal/ServletOutputStreamImpl.write(ServletOutputStream
>>Impl.java:169) at
>> org/apache/cxf/io/AbstractWrappedOutputStream.write(AbstractWrappedOutputSt
>>ream.java:46) at
javax/activation/DataHandler.writeTo(DataHandler.java:290)
>> at
>> org/apache/cxf/attachment/AttachmentSerializer.writeAttachments(AttachmentS
>>erializer.java:153) at
>> org/apache/cxf/interceptor/AttachmentOutInterceptor$AttachmentOutEndingInte
>>rceptor.handleMessage(AttachmentOutInterceptor.java:80) at
>> org/apache/cxf/phase/PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>>n.java:236) ^-- Holding lock:
>> org/apache/cxf/phase/phaseinterceptorch...@0x102dafd8[thin lock]
>> at
>> org/apache/cxf/interceptor/OutgoingChainInterceptor.handleMessage(OutgoingC
>>hainInterceptor.java:74) at
>> org/apache/cxf/phase/PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>>n.java:236) ^-- Holding lock:
>> org/apache/cxf/phase/phaseinterceptorch...@0x102cef90[thin lock]
>> at
>> org/apache/cxf/transport/ChainInitiationObserver.onMessage(ChainInitiationO
>>bserver.java:89) at
>> org/apache/cxf/transport/servlet/ServletDestination.invoke(ServletDestinati
>>on.java:99) at
>> org/apache/cxf/transport/servlet/ServletController.invokeDestination(Servle
>>tController.java:368) at
>> org/apache/cxf/transport/servlet/ServletController.invoke(ServletController
>>.java:183) at
>> org/apache/cxf/transport/servlet/AbstractCXFServlet.invoke(AbstractCXFServl
>>et.java:163) at
>> org/apache/cxf/transport/servlet/AbstractCXFServlet.doPost(AbstractCXFServl
>>et.java:141) at
javax/servlet/http/HttpServlet.service(HttpServlet.java:763)
>> at javax/servlet/http/HttpServlet.service(HttpServlet.java:856) at
>> weblogic/servlet/internal/StubSecurityHelper$ServletServiceAction.run(StubS
>>ecurityHelper.java:227) at
>> weblogic/servlet/internal/StubSecurityHelper.invokeServlet(StubSecurityHelp
>>er.java:125) at
>> weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:283)
>> at
>> weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:175)
>> at
>> weblogic/servlet/internal/WebAppServletContext$ServletInvocationAction.run(
>>WebAppServletContext.java:3231) at
>> weblogic/security/acl/internal/AuthenticatedSubject.doAs(AuthenticatedSubje
>>ct.java:321) at
>> weblogic/security/service/SecurityManager.runAs(SecurityManager.java:121)
>> at
>> weblogic/servlet/internal/WebAppServletContext.securedExecute(WebAppServlet
>>Context.java:2002) at
>> weblogic/servlet/internal/WebAppServletContext.execute(WebAppServletContext
>>.java:1908) at
>> weblogic/servlet/internal/ServletRequestImpl.run(ServletRequestImpl.java:13
>>62) at weblogic/work/ExecuteThread.execute(ExecuteThread.java:209) at
>> weblogic/work/ExecuteThread.run(ExecuteThread.java:181)
>> at jrockit/vm/RNI.c2java(IIIII)V(Native Method)
>> -- end of trace
>>
>>
>> Bye,
>> Marco
>>
>> dkulp wrote:
>> > On Wed July 29 2009 5:30:13 am dp-isp wrote:
>> >> Sorry if my question is trivial... in order to test your fixes, can I
>> >> download the latest snapshot
>> >>
>> (http://repository.apache.org/snapshots/org/apache/cxf/apache-cxf/2.2.3-
>> >>SNA PSHOT/) or there is a better way?
>> >
>> > Yea. But testing out the actual 2.2.3 release candidate that we are
>> > voting on
>> > would be good as well:
>> >
>> https://repository.apache.org/content/repositories/cxf-staging-003/org/ap
>> >ache/cxf/apache-cxf/2.2.3
>> >
>> > Dan
>> >
>> >> Thanks,
>> >> Marco
>> >>
>> >> dkulp wrote:
>> >> > Well, I THOUGHT this would have been easily doable, but when I
>> >> > checked, it turns out the attachments were not streaming properly in
>> >> > MTOM mode.
>> >> >
>> >> > :-(
>> >> >
>> >> > I've gone through and fixed a BUNCH of things related to the
>> >> > attachment handling and streaming and such so some of this is now
>> >> > possible.
>> >> >
>> >> > Now, with the latest code, when you get the DataSource, if at all
>> >> > possible,
>> >> > the input stream that is returned will properly be streaming off the
>> >>
>> >> wire
>> >>
>> >> > instead of cached. Thus, you can copy directly from there to the
>> >>
>> >> output
>> >>
>> >> > stream.
>> >> >
>> >> > There are cases where this WON'T work stream directly, notably when
>> >> > schema validation is turned on. In that case, to work around
>> issues
>> >>
>> >> in
>> >>
>> >> > JAXB, we buffer the content. Also, if there are multiple
>> >>
>> >> attachments,
>> >>
>> >> > only the last
>> >> > one can really be streamed this way. The others get buffered.
>> >> >
>> >> > Dan
>> >> >
>> >> > On Mon July 27 2009 5:50:00 am dp-isp wrote:
>> >> >> Hello everybody,
>> >> >>
>> >> >> We have a CXF webservice that is a kind of "repository service" and
>> a
>> >> >> webapp working as frontend for that repository.
>> >> >> Those two components are on separate hosts.
>> >> >>
>> >> >> We would need to realize a continuous stream of data when
>> downloading
>> >> >> attachments from CXF webservice to the users' browser through the
>> >> >> frontend
>> >> >> webapp.
>> >> >>
>> >> >> The webapp is basically a servlet that invokes the webservice,
>> >>
>> >> receives
>> >>
>> >> >> the
>> >> >> attachment datahandler and copies datahandler InputStream to
>> servlet
>> >> >> response OutputStream (servlet code is at the end of this email).
>> >> >>
>> >> >> Our issue: is it possible to directly link datahandler InputStream
>> to
>> >> >> servlet response OutputStream without re-building the whole
>> >> >> attachment in memoroy or in a temporary file? (as can be configured
>> >> >> by setting org.apache.cxf.io.CachedOutputStream.Threshold,
>> >> >> org.apache.cxf.io.CachedOutputStream.OutputDirectory)
>> >> >>
>> >> >> Going more into details, is there a way to send to CXF the output
>> >>
>> >> buffer
>> >>
>> >> >> to
>> >> >> write the attachment on? In such case we would send to CXF the
>> >>
>> >> sevlet's
>> >>
>> >> >> output buffer.
>> >> >>
>> >> >> Alternatively, is there a way to manage CXF working asynchronously
>> >>
>> >> with
>> >>
>> >> >> attachments, giving back control to the servlet before attachment
>> >> >> downolad
>> >> >> completion?
>> >> >>
>> >> >> Many thanks,
>> >> >> Marco
>> >> >>
>> >> >> ---
>> >> >>
>> >> >> This is the servlet's involved code:
>> >> >>
>> >> >> ...
>> >> >> StreamingService_Service ss = new StreamingService_Service(new
>> >> >> URL(serviceURL));
>> >> >> StreamingService port = ss.getServiceImplPort(new MTOMFeature());
>> >> >>
>> >> >> Resume myFile = port.downloadMethod(fileName, fileType, usr, pwd,
>> >>
>> >> repo);
>> >>
>> >> >> DataHandler handler = myFile.getResume();
>> >> >>
>> >> >> response.setHeader("Pragma", "No-cache");
>> >> >> response.setContentType("application/octet-stream");
>> >> >> response.setHeader("content-disposition", "attachment; filename=" +
>> >> >> fileName + "." + fileType);
>> >> >> try {
>> >> >> InputStream is = handler.getInputStream();
>> >> >> try {
>> >> >> OutputStream os = response.getOutputStream();
>> >> >> try {
>> >> >> byte[] b = new byte[100000];
>> >> >> int bytesRead = 0;
>> >> >> while ((bytesRead = is.read(b)) != -1) {
>> >> >> os.write(b, 0, bytesRead);
>> >> >> }
>> >> >> System.out.println("Download del file " +
>> >> >> myFile.getCandidateName()
>> >>
>> >> +
>> >>
>> >> >> "." + myFile.getResumeFileType() + " completato.");
>> >> >> } finally {
>> >> >> os.flush();
>> >> >> os.close();
>> >> >> }
>> >> >> } finally {
>> >> >> is.close();
>> >> >> }
>> >> >>
>> >> >> } catch (Exception e) {
>> >> >> e.printStackTrace();
>> >> >> }
>> >> >> ...
>> >> >
>> >> > --
>> >> > Daniel Kulp
>> >> > [email protected]
>> >> > http://www.dankulp.com/blog
>> >
>> > --
>> > Daniel Kulp
>> > [email protected]
>> > http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> [email protected]
> http://www.dankulp.com/blog
>
>
--
View this message in context:
http://www.nabble.com/Streaming-large-attachments-by-linking-input-and-output-stream-avoiding-temp-files-tp24677330p24743365.html
Sent from the cxf-user mailing list archive at Nabble.com.