quarkus: RESTEASY: Unable to find a MessageBodyReader for media type: text/plain; charset=us-ascii and class type java.util.Map
@POST
@Path("/import")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces({MediaType.APPLICATION_JSON})
@Transactional
public Response myFileImport(@MultipartForm MyImportData importData) {
[...]
}
public class MyImportData {
@FormParam("myFile")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
public InputStream inputStream;
@FormParam("myMapping")
@PartType(MediaType.APPLICATION_JSON)
public Map<Integer, String> myMapping;
}
Exception:
Marcus Biel: java.lang.RuntimeException: RESTEASY007545: Unable to find a MessageBodyReader for media type: text/plain; charset=us-ascii and class type java.util.Map
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$PartImpl.getBody(MultipartInputImpl.java:226)
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.setFields(MultipartFormAnnotationReader.java:189)
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.readFrom(MultipartFormAnnotationReader.java:79)
at org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:101)
at org.jboss.resteasy.core.interception.jaxrs.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:63)
at org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:80)
media type: text/plain is confusing, since I set APPLICATION_JSON as the type - but it gave me the hint for a quick hack: Putting media type: text/plain and a String Java type, then converting the raw Json String with a Jackson Objectmapper in my Java code myself. I guess I need to provide a custom MessageBodyReader, but I couldn’t get this to work quickly, so I went with my hack instead.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
Rollback back to 1.8.1.Final. This is a BIG blocker for me.