dev@jersey.java.net

Re: Invalid media type

From: Fred <frederic.auguste_at_gmail.com>
Date: Fri, 27 Jul 2007 09:49:21 +0200

Jakub,

See below my stak trace :

java.lang.IllegalArgumentException: Invalid media type:
multipart/form-data; boundary=Thread:0000_at_Round:0001
        javax.ws.rs.core.MediaType.&lt;init&gt;(MediaType.java:84)
        com.sun.ws.rest.impl.model.HttpHelper.getContentType(HttpHelper.java:110)
        com.sun.ws.rest.impl.model.HttpHelper.getContentType(HttpHelper.java:99)
        com.sun.ws.rest.impl.model.method.ResourceMethodMapDispatcher.dispatch(ResourceMethodMapDispatcher.java:69)
        com.sun.ws.rest.impl.model.BaseResourceClass.dispatch(BaseResourceClass.java:68)
        com.sun.ws.rest.impl.application.WebApplicationContext.dispatchTo(WebApplicationContext.java:102)
        com.sun.ws.rest.impl.model.ClassDispatcher.dispatch(ClassDispatcher.java:43)
        com.sun.ws.rest.impl.model.BaseResourceClass.dispatch(BaseResourceClass.java:68)
        com.sun.ws.rest.impl.model.RootResourceClass.dispatch(RootResourceClass.java:122)
        com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:156)
        com.sun.ws.rest.impl.container.servlet.ServletAdaptor.service(ServletAdaptor.java:130)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Fred

Hi Fred,

could you please provide the exception stack trace (perhaps from your
server log)?

Thanks,

~Jakub


2007/7/26, Fred <frederic.auguste_at_gmail.com>:
> Hi,
>
> I am working with jersey 0.2.
>
> I defined a resource with these anotations :
> @HttpMethod("POST")
> @UriTemplate("/{version}/{toto}")
> @ConsumeMime("multipart/form-data")
> @ProduceMime("application/atom+xml")
>
>
> When I send a request with the following content-type in my request header
> Content-Type: multipart/form-data; boundary=Thread:0000_at_Round:0001
> I have the following error :
> java.lang.IllegalArgumentException : Invalid media type: multipart/form-data; boundary=Thread:0000_at_Round:0001
>
> If I use the following content-type in the header, the response is correct.
> Content-Type: multipart/form-data; boundary=GbSqW2a9GNsRqKSfkfYTN346mgofBgm0uUa4_slb
>
> Is my content type is wrong or is it a bug in jersey ?
>
> Thanks for your response.
>
> Best regards,
> Frédéric
>