users@jersey.java.net

[Jersey] Re: Jersey 1.5 ClientHandlerException - ClientResponse.getEntity(Multipart.class)

From: Radhika <radhika.kv_at_gmail.com>
Date: Wed, 11 May 2011 23:35:10 -0700 (PDT)

One another problem occurred after the jersey and related jars were upgraded
from 1.1.2 to 1.5.

One of our restful resource method consumes multipart/mixed mediatype.

@POST
@Consumes("multipart/mixed")
public Response storeFile(final MultiPart multiPart) {
...... }

The method is invoked as below:

ClientResponse response = addHeaders(service.path("/storefile")
.getRequestBuilder()).type("multipart/mixed")
.post(ClientResponse.class, multiPart);

However I get the 415 Unsupported Media Type error as below (with Jersey
logging filter enabled).
Looks like the request is automatically appending boundary value in
Content-Type and there is no such resource method. I tried to provide a
hardcoded boundary value both in the request and in the @Consumes annotation
of the resource method.This too gives back only a 415 error.

02:26:34(05/12) INFO com.mycompany.logging.SmapiContainerLoggingFilter : 2
* Server in-bound request
2 > POST http://localhost:8080/storefile
2 > Content-Type:
multipart/mixed;boundary=Boundary_1_22363432_13051815942012 > MIME-Version:
1.0
2 > User-Agent: Java/1.6.0_21
2 > Host: localhost:8080
2 > Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
2 > Connection: keep-alive
2 > Content-Length: 321327
2 >

May 12, 2011 2:26:34 AM com.sun.jersey.spi.container.ContainerRequest
getEntity
SEVERE: A message body reader for Java class
com.sun.jersey.multipart.MultiPart, and Java type class
com.sun.jersey.multipart.MultiPart, and MIME media type
multipart/mixed;boundary=Boundary_1_22363432_1305181594201 was not found
May 12, 2011 2:26:34 AM com.sun.jersey.spi.container.ContainerRequest
getEntity
SEVERE: The registered message body readers 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.SourceProvider$StreamSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
  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.core.impl.provider.entity.XMLRootElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
  com.sun.jersey.core.impl.provider.entity.EntityHolderReader
  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


02:26:34(05/12) INFO com.mycompany.logging.SmapiContainerLoggingFilter : 2
* Server out-bound response
2 < 415
2 < Content-Type: text/xml
2 <
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error
xmlns="http://services.lexisnexis.com/xmlschema/servicefault/1"><date>2011-05-12T02:26:34.545-04:00</date><responsecode>415
Unsupported Media
Type</responsecode><name>com.sun.jersey.api.MessageException: A message body
reader for Java class com.sun.jersey.multipart.MultiPart, and Java type
class com.sun.jersey.multipart.MultiPart, and MIME media type
multipart/mixed;boundary=Boundary_1_22363432_1305181594201 was not
found</name><code>com.sun.jersey.spi.container.ContainerRequest::getEntity::443</code><severity>1</severity><requestid></requestid></error>



--
View this message in context: http://jersey.576304.n2.nabble.com/Jersey-1-5-ClientHandlerException-ClientResponse-getEntity-Multipart-class-tp6354471p6354655.html
Sent from the Jersey mailing list archive at Nabble.com.