I have a jersey based web service which produces a "multipart/mixed" RESPONSE as follows: The method reads a file, and should return it in octet format. Also, it read the metadata of that file and returns them in json form.
Method:
@GET
@Produces("multipart/mixed")
public Multipart getDocumentContents(@Context HttpHeaders header){
....
....
....
os = new ByteArrayOutputStream();
....
....
MultiPart multiPartEntity = new MultiPart()
.bodyPart(new BodyPart(os.toByteArray(), MediaType.APPLICATION_OCTET_STREAM_TYPE));
return multiPartEntity;
}
My problem is that I get the following error which does not make sense to me:
A message body writer for Java class com.sun.jersey.multipart.MultiPart, and Java type class com.sun.jersey.multipart.MultiPart, and MIME media type multipart/mixed was not found
06.08.2013 15:32:06 com.sun.jersey.spi.container.ContainerResponse write
SCHWERWIEGEND: The registered message body writers compatible with the MIME media type are:
*/* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.json.impl.provider.entity.JSONWithPaddingProvider
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
As far as I know, os.toByteArray() is converting my object into Byte array.
Any idea?
EDIT: I am using Jersey 1.15