users@jersey.java.net

[Jersey] Uploading file does not produce needed type of response

From: Sigmar Muuga <meediake_at_gmail.com>
Date: Sat, 19 Nov 2011 18:15:09 +0200

Hi!

My current upload resource is like this:

@Path("/upload")
@Produces(MediaType.TEXT_PLAIN)
public class UploadResource {

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile() {
        }
}

As you can see, this resource accepts multipart/form-data and it *should*
respond with media type of "text/plain".

But when I am running it, I get error something like this:

javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A
message body writer for Java class com.service.model.ImageUploadInfo, and
Java
 type class com.service.model.ImageUploadInfo, and MIME media type
multipart/form-data; boundary=----WebKitFormBoundary44OfVYPW6Wv6QOw7 was
not found.

I am using jersey-multipart from jersey contribs.

Does somebody have idea, why it is not working as expected?

Sigmar