Skip to content

smallrye client 'Cannot construct instance of java.util.ArrayList' #1228

@johnaohara

Description

@johnaohara

When calling a rest endpoint that returns a List from a native application using smallrye rest client;

e.g.

    @Inject
    @RestClient
    IWidgetsService widgetsService;
...
    private List<String> getWidgets() {
        return widgetsService.getWidgets();
    }

with IWidgetsService defined as;

@Path("/")
@Produces("application/json")
@RegisterRestClient
public interface IWidgetsService {

    @GET
    @Path("widgets")
    List<String> getWidgets() ;

}

Causes the following exception;

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.util.ArrayList` (no Creators, like default construct, exist): no default no-arguments constructor found
 at [Source: (org.jboss.resteasy.client.jaxrs.internal.ClientResponse$InputStreamWrapper); line: 1, column: 1]

We need to register ArrayList for reflection so that it is available at runtime in the native service

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions