Eugene Goldberg Eugene Goldberg - 1 year ago 491
Java Question

spring boot - how to avoid "Failed to instantiate [java.util.List]: Specified class is an interface" in HHTP controller handler?

In my spring boot REST API application, I need to handle HTTP POST by accepting a strongly-typed list as my input:

public class CusttableController {

static final Logger LOG = LoggerFactory.getLogger(CusttableController.class);

@RequestMapping(value="/custtable/update", method=RequestMethod.POST)
public String updateCusttableRecords(List<Custtable> customers) {
try {
for (Custtable cust : customers) {

Custtable customer = (Custtable) custtableDao.getById(Custtable.class,
new CusttableCompositeKey

In the Jersey version of this API, this worked just fine, but with Spring Boot, it gives me this error:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface

What is the proper way for me to accept a strongly-typed List in Spring Boot?

Answer Source

Try to add RequestBody annotation to your method definition

@RequestMapping(value="/custtable/update", method=RequestMethod.POST)
public String updateCusttableRecords(@RequestBody List<Custtable> customers) {
    //Method body 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download