Search code examples
javamavenresteasy

Resteasy 2.3.10.Final ClientResponse.readEntity AbstractMethodError


I am currently trying to create a Resteasy Client, having to use Version 2.3.10.Final. Unfortunately, I should not use a newer Version. I am very new to this, so I hope I manage to provide all required Information to make this question answerable.

First, the Request is created and finally "PUT". The returned ClientResponse is to be evaluated.

I can successfully call

Response.getStatus()

showing me that the "PUT" has been successful, as the Status is equal to

Response.Status.CREATED.getStatusCode()

However, any attempt to call response.readEntity Returns the error

java.lang.AbstractMethodError: javax.ws.rs.core.Response.readEntity(Ljava/lang/Class;)Ljava/lang/Object;
at blabla.evaluateResponse(MyResteasyClient.java:80)´

This is for any attempt to call .readEntity, but for the sake of specificity, let's concentrate on

String entity = Response.readEntity(String.class);

When attempting response.getEntity(), it Returns the following error message:

java.lang.RuntimeException: RESTEASY001555: No type information to extract entity with, use other getEntity() methods
at org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:337)
at blabla.evaluateResponse(MyResteasyClient.java:81)

Am I even on the right Track? My Goal is to achieve something along the lines of:

List<? extends MyResponse> myResponses = response.readEntity(new GenericType<List<MyResponse>>() {});

Where the class "MyResponse" is an implementation of the Interface

public interface MyPartialResponse {
boolean isSuccessful();
String getMessage();
}

The dependencies within pom.xml are:

<properties>
    <version.jackson>2.6.5</version.jackson>
    <version.resteasy-client>2.3.10.Final</version.resteasy-client>
</properties>

<dependencies>
    (removed a company specific dependency)
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>${version.resteasy-client}</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson-provider</artifactId>
        <version>${version.resteasy-client}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${version.jackson}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${version.jackson}</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.6</version>
    </dependency>
</dependencies>

Solution

  • If anyone happens to land on this question with the same error, let me provide the answer, how I solved my issue:

    By adding

    BaseClientResponse<?> r = (BaseClientResponse<?>) response;
    

    I could successfully call

    r.getEntity(new GenericType<List<MyResponse>>() {});