Thanks, by the way, I fixed the issue locally, fix going in shortly

Cheers, Sergey
On 20/12/12 11:53, Malisetti, Ramanjaneyulu wrote:
I traced out the problem, it is with following line

             Attachment respXMLPayloadAttachment = new Attachment("Response_XML_Payload", 
"application/xml",
                     responsePayload.getBytes());

I no longer see problem if  I change this to

            InputStream responseStream = new 
ByteArrayInputStream(responsePayload.getBytes());
             MultivaluedMap<String, String>  headers = new MetadataMap<String, 
String>();
             ContentDisposition cd = new 
ContentDisposition("Response_XML_Payload");
             headers.putSingle("Content-ID", "Response_XML_Payload");
             headers.putSingle("Content-Disposition", cd.toString());
             headers.putSingle("Content-Type", "application/xml");
             Attachment respXMLPayloadAttachment = new 
Attachment(responseStream, headers);

Regards
Raman

From: Malisetti, Ramanjaneyulu
Sent: Thursday, December 20, 2012 2:43 PM
To: users@cxf.apache.org
Subject: MultipartBody gives java.lang.IllegalStateException: !empty with CXF 
2.7.1

Hi,
             We have the following code which used to work with CXF 2.5.2  but 
getting the below exception with CXF 2.7.1

         Map<String, InputStream>  attachments = files;
             List<Attachment>  attachments = new ArrayList<Attachment>();

             /* First attachment is always the Response payload */
             Attachment respXMLPayloadAttachment = new Attachment("Response_XML_Payload", 
"application/xml",
                     responsePayload.getBytes());
             attachments.add(respXMLPayloadAttachment);

             Set<String>  attachmentFileNames = files.keySet();
             for (String fileName : attachmentFileNames) {
                 ContentDisposition cd = new 
ContentDisposition("attachment;filename=" + fileName);
                 attachments.add(new Attachment(fileName, files.get(fileName), 
cd));
             }
             return new MultipartBody(attachments);


we are getting response but status code is 500 because of the below exception

Response:
------------------------------
--uuid:32188b25-724d-400a-8ba4-a8c693874318
Content-Type: application/xml
Content-Transfer-Encoding: binary
Content-ID:<Response_XML_Payload>

Error serializing the response, please check the server logs, response class : 
MultipartBody.
--uuid:32188b25-724d-400a-8ba4-a8c693874318
Content-Type: application/xml
Content-Transfer-Encoding: binary
Content-ID:<console-output.txt>

<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat";><ns1:faultstring 
xmlns:ns1="http://cxf.apache.org/bindings/xformat";>java.lang.IllegalStateException: 
!empty</ns1:faultstring></ns1:XMLFault>
-------------------------------


Exception on Server side:

java.lang.IllegalStateException: !empty
                 at 
org.eclipse.jetty.server.AbstractHttpConnection$Output.sendContent(AbstractHttpConnection.java:1053)
                 at 
org.apache.cxf.transport.http_jetty.JettyHTTPDestination$JettyOutputStream.copyFrom(JettyHTTPDestination.java:405)
                 at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:102)
                 at 
org.apache.cxf.transport.http.AbstractHTTPDestination$WrappedOutputStream.copyFrom(AbstractHTTPDestination.java:698)
                 at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:102)
                 at 
org.apache.cxf.helpers.IOUtils.copyAndCloseInput(IOUtils.java:110)
                 at 
org.apache.cxf.jaxrs.provider.BinaryDataProvider.copyInputToOutput(BinaryDataProvider.java:135)
                 at 
org.apache.cxf.jaxrs.provider.BinaryDataProvider.writeTo(BinaryDataProvider.java:104)
                 at 
org.apache.cxf.jaxrs.provider.MultipartProvider$MessageBodyWriterDataHandler.writeTo(MultipartProvider.java:456)
                 at 
org.apache.cxf.jaxrs.provider.MultipartProvider.writeTo(MultipartProvider.java:265)
                 at 
org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1216)
                 at 
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:259)
                 at 
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:155)
                 at 
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:86)
                 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.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:354)
                 at 
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:318)
                 at 
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
                 at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067)
                 at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1003)
                 at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
                 at 
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
                 at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
                 at org.eclipse.jetty.server.Server.handle(Server.java:350)
                 at 
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
                 at 
org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:900)
                 at 
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:954)
                 at 
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851)
                 at 
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
                 at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
                 at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:620)
                 at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
                 at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
                 at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
                 at java.lang.Thread.run(Thread.java:722)
     2012-12-20 12:03:28,018 WARN  [qtp12593459-146] 
interceptor.JAXRSOutInterceptor -101-org.apache.cxf.bundle-2.7.1 - Error 
serializing the response, please check the server logs, response class : 
MultipartBody..

Regards
Raman



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to