1

I'm using the resteasy client with the jackson provider. Here is the build.gradle snippet:

compile "org.jboss.resteasy:resteasy-jaxrs:3.6.2.Final"
compile "org.jboss.resteasy:resteasy-client:3.6.2.Final"
compile "org.jboss.resteasy:resteasy-jackson2-provider:3.6.2.Final"

The line in which I deal with the server response is

(List<String>) response.readEntity(List.class)

(the server returns a List<String> and the request method is annotated with @Produces(MediaType.APPLICATION_JSON))

When I run the client from within Eclipse everything is fine, but after I create a JAR with gradle (task: jar) and launch it and do the request, I get:

javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type interface java.util.List
    at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:37)
    at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80)
    at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:334)
    at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:261)
    at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:237)

... (at the line (List<String>) response.readEntity(List.class))

Inside META-INF\services\ of the jar there are 2 javax.ws.rs.ext.Providers files:

org.jboss.resteasy.plugins.providers.DataSourceProvider
org.jboss.resteasy.plugins.providers.DocumentProvider
org.jboss.resteasy.plugins.providers.DefaultTextPlain
org.jboss.resteasy.plugins.providers.DefaultNumberWriter
org.jboss.resteasy.plugins.providers.DefaultBooleanWriter
org.jboss.resteasy.plugins.providers.StringTextStar
org.jboss.resteasy.plugins.providers.SourceProvider
org.jboss.resteasy.plugins.providers.InputStreamProvider
org.jboss.resteasy.plugins.providers.ReaderProvider
org.jboss.resteasy.plugins.providers.ByteArrayProvider
org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider
org.jboss.resteasy.plugins.providers.JaxrsFormProvider
org.jboss.resteasy.plugins.providers.CompletionStageProvider
org.jboss.resteasy.plugins.providers.ReactiveStreamProvider
org.jboss.resteasy.plugins.providers.FileProvider
org.jboss.resteasy.plugins.providers.FileRangeWriter
org.jboss.resteasy.plugins.providers.StreamingOutputProvider
org.jboss.resteasy.plugins.providers.IIOImageProvider
org.jboss.resteasy.plugins.interceptors.CacheControlFeature
org.jboss.resteasy.plugins.interceptors.encoding.ClientContentEncodingAnnotationFeature
org.jboss.resteasy.plugins.interceptors.encoding.ServerContentEncodingAnnotationFeature
org.jboss.resteasy.plugins.interceptors.encoding.MessageSanitizerContainerResponseFilter
org.jboss.resteasy.plugins.providers.sse.SseEventProvider
org.jboss.resteasy.plugins.providers.sse.SseEventOutputProvider
org.jboss.resteasy.plugins.providers.sse.SseEventSinkInterceptor

and

org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider
org.jboss.resteasy.plugins.providers.jackson.UnrecognizedPropertyExceptionHandler
org.jboss.resteasy.plugins.providers.jackson.PatchMethodFilter

So the jackson2 provider seems to be listed.

Questions I looked at:

RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse

Unable to find a MessageBodyReader of content-type application/json and type class java.lang.String

Unable to find a MessageBodyReader of content-type text/html and type interface java.util.List

I don't know if the problem is in the gradle task of creating the jar, the jackson provider, resteasy...

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
Mark
  • 2,167
  • 4
  • 32
  • 64
  • Aside from the incorrect use of readEntity() for generics (see [Shubhendu Pramanik's answer](https://stackoverflow.com/a/53761108/2587435)), your problem looks like [this](https://stackoverflow.com/q/53751401/2587435) – Paul Samsotha Dec 13 '18 at 12:08
  • @PaulSamsotha thanks, but I have the same question as to him: why does it work from the IDE if the code is wrong? – Mark Dec 13 '18 at 12:30
  • My comment said "Aside" from the code. It's not the code that is the problem. The code is just not the correct way of doing it. Read all the comments and links in the post I linked to and my answer to understand the real problem. It is with those Provider files and how there can only be one when you make a fat jar. – Paul Samsotha Dec 13 '18 at 16:09
  • @PaulSamsotha I see. Using the `shadowJar` task keeps only the second provider files and now the request works. Thanks! The answer you linked to is deleted i guess but the problem in the code i'll be able to handle myself. – Mark Dec 13 '18 at 16:40

0 Answers0