Hi

Perhaps the target server closed the connection after processing the first attachment ? I can not see any issues with the client code.

Sergey
On 23/05/17 11:09, nicolasduminil wrote:
Hi,

Apache CXF 3.0.3 comes bundled with WebSphere 9.0.0.3 accordingly I cannot
replace the libraries. I could deploy another release of CXF with my WAR
but, in this case, it would conflict with the classes already deployed into
the app server. I could also modify the class-loading strategy such that to
use the classes bundled into the WAR rather then the ones provide by the app
server, but then I would fall into other issues. And anyway, wether this
works or not, at the end of the day I need to work with what is provided by
WebSphere, as there is no other option.

So, replacing CXF 3.0.3 by 3.0.13 wouldn't have any benefice, wether it
works or not.

But I noticed that the the exception:

org.apache.cxf.interceptor.Fault: No message body writer has been found for
class org.apache.cxf.jaxrs.ext.multipart.MultipartBody, ContentType:
multipart/form-data

is caused by the following:

Caused by: java.io.IOException: Stream Closed
         at java.io.FileInputStream.available(Native Method)
         at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:148)
         at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:107)
         at
org.apache.cxf.helpers.IOUtils.copyAndCloseInput(IOUtils.java:113)
         at
org.apache.cxf.jaxrs.provider.BinaryDataProvider.copyInputToOutput(BinaryDataProvider.java:186)
         at
org.apache.cxf.jaxrs.provider.BinaryDataProvider.writeTo(BinaryDataProvider.java:146)
         at
org.apache.cxf.jaxrs.provider.MultipartProvider$MessageBodyWriterDataHandler.writeTo(MultipartProvider.java:457)

So, I'm trying to construct a multipart having several PDF files and I'm
wondering if the way I'm constructing the multipart is correct. Here is the
code:

     File[] files = new File(".").listFiles(new FilenameFilter()
     {
       @Override
       public boolean accept(File dir, String name)
       {
         return name.endsWith(".pdf");
       }
     });
     List<Attachment> attachments = new LinkedList<Attachment>();
     for (File file : files)
       try (FileInputStream stream = new FileInputStream(file);)
       {
         ContentDisposition cd = new ContentDisposition("filename=" +
file.getName());
         attachments.add(new Attachment(file.getName(),
MediaType.APPLICATION_OCTET_STREAM, stream));

And when I do:

webClient.post(new MultipartBody(attachments));

It raises this exception saying that input streams are closed. Do you see
any reason that streams be closed here ?

Many thanks in advance.

Kind regards,

Nicolas DUMINIL



--
View this message in context: 
http://cxf.547215.n5.nabble.com/CXF-3-0-3-org-apache-cxf-interceptor-Fault-No-message-body-writer-has-been-found-for-class-org-apacha-tp5780611p5780629.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to