Regards,
Stephan
org.apache.cxf.jaxrs.provider.MultipartProvider readFrom()
org.apache.cxf.interceptor. AttachmentInInterceptor handleMessage()
Thread [qtp14633156-18 - /odata.svc/$batch] (Suspended (breakpoint at
line
60 in AttachmentInInterceptor))
owns: PhaseInterceptorChain (id=65)
AttachmentInputInterceptor(AttachmentInInterceptor).handleMessage(Message
)
line: 60
MessageContextImpl.createAttachments(String) line: 235
MessageContextImpl.get(Object) line: 73
ThreadLocalMessageContext.get(Object) line: 38
AttachmentUtils.getMultipartBody(MessageContext, String,
String,
String) line: 89
AttachmentUtils.getAttachments(MessageContext, String, String,
String) line: 94
MultipartProvider.readFrom(Class<Object>, Type, Annotation[],
MediaType, MultivaluedMap<String,String>, InputStream) line: 136
JAXRSUtils.readFromMessageBody(Class<T>, Type, Annotation[],
InputStream, MediaType, List<MediaType>, Message) line: 1038
JAXRSUtils.processParameter(Class<?>, Type, Annotation[],
Parameter, MultivaluedMap<String,String>, Message,
OperationResourceInfo)
line: 614
JAXRSUtils.processParameters(OperationResourceInfo,
MultivaluedMap<String,String>, Message) line: 578
JAXRSInInterceptor.processRequest(Message) line: 238
JAXRSInInterceptor.handleMessage(Message) line: 89
PhaseInterceptorChain.doIntercept(Message) line: 262
ChainInitiationObserver.onMessage(Message) line: 122
ServletDestination(AbstractHTTPDestination).invoke(ServletConfig,
ServletContext, HttpServletRequest, HttpServletResponse) line: 211
ServletController.invokeDestination(HttpServletRequest,
HttpServletResponse, AbstractHTTPDestination) line: 213
ServletController.invoke(HttpServletRequest,
HttpServletResponse)
line: 154
CXFNonSpringJaxrsServlet(CXFNonSpringServlet).invoke(HttpServletRequest,
HttpServletResponse) line: 129
CXFNonSpringJaxrsServlet(AbstractHTTPServlet).handleRequest(HttpServletRe
qu
est, HttpServletResponse) line: 187
CXFNonSpringJaxrsServlet(AbstractHTTPServlet).doPost(HttpServletRequest,
HttpServletResponse) line: 110
CXFNonSpringJaxrsServlet(HttpServlet).service(HttpServletRequest,
HttpServletResponse) line: 727
CXFNonSpringJaxrsServlet(AbstractHTTPServlet).service(ServletRequest,
ServletResponse) line: 166
ServletHolder.handle(Request, ServletRequest, ServletResponse)
line: 547
ServletHandler.doHandle(String, Request, HttpServletRequest,
HttpServletResponse) line: 480
SessionHandler.doHandle(String, Request, HttpServletRequest,
HttpServletResponse) line: 225
ServletContextHandler(ContextHandler).doHandle(String, Request,
HttpServletRequest, HttpServletResponse) line: 940
ServletHandler.doScope(String, Request, HttpServletRequest,
HttpServletResponse) line: 409
SessionHandler.doScope(String, Request, HttpServletRequest,
HttpServletResponse) line: 186
ServletContextHandler(ContextHandler).doScope(String, Request,
HttpServletRequest, HttpServletResponse) line: 874
ServletContextHandler(ScopedHandler).handle(String, Request,
HttpServletRequest, HttpServletResponse) line: 117
HandlerCollection.handle(String, Request, HttpServletRequest,
HttpServletResponse) line: 149
Server(HandlerWrapper).handle(String, Request,
HttpServletRequest,
HttpServletResponse) line: 110
Server.handle(HttpConnection) line: 345
SelectChannelConnector$SelectChannelHttpConnection(HttpConnection).handle
Re
quest() line: 441
HttpConnection$RequestHandler.content(Buffer) line: 936
HttpParser.parseNext() line: 801
HttpParser.parseAvailable() line: 224
SelectChannelConnector$SelectChannelHttpConnection(AsyncHttpConnection).h
an
dle() line: 52
SelectChannelEndPoint.handle() line: 586
SelectChannelEndPoint$1.run() line: 44
QueuedThreadPool.runJob(Runnable) line: 598
QueuedThreadPool$3.run() line: 533
Thread.run() line: not available
On 12/11/12 2:46 PM, "Sergey Beryozkin"<[email protected]> wrote:
Stephan, by the way, I'm not seeing
'MailAttachmentInterceptor' in CXF source...
Cheers, Sergey
On 11/12/12 13:44, Sergey Beryozkin wrote:
Hi Stephan
On 11/12/12 13:17, Klevenz, Stephan wrote:
Dear CXF Gurus and Community!
I want to consume a multipart/mixed payload via a stream like shown
in
the example code below. Unfortunately it seems that injected stream
is
already closed and can not be used anymore. Debugging CXF shows that
a
MailAttachmentInterceptor has taken the stream before it is injected.
Is there an option to avoid that behavior?
Thanks in advance.
Greetings,
Stephan
@POST
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
public StreamingOutput createItem(InputStream requestBodyStream) {
/* read the requestBodyStream like a normal input stream */
return new StreamingOutput() {
public void write(OutputStream output) throws IOException,
WebApplicationException {
byte[] out = /* get some bytes to write */
output.write(out);
}
})
}
Can you replace the above with
public StreamingOutput createItem(MultipartBody body) {
// assuming a single attachment:
InputStream is =
body.getRootAttachment().getObject(InputStream.class);
//or
InputStream is = body.getAttachmentObject("partId",
InputStream.class);
}
Quite a few other options are also possible, please see
http://cxf.apache.org/docs/jax-rs-multiparts.html
Let me know please if it works for you
HTH, Sergey