Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
790 views
in Technique[技术] by (71.8m points)

rest - Spring Boot Application: No converter found for return value of type

I am writing a simple REST API according to this Spring-Boot tutorial. On my local dev machines (Ubuntu 15.04 and Windows 8.1) everything works like a charm.

I have an old 32-bit Ubuntu 12.04 LTS server lying around on which I wanted to deploy my REST service.

The starting log is ok, but as soon as I send a GET request to the /user/{id} endpoint, I get the following error:

java.lang.IllegalArgumentException: No converter found for return value of type: class ch.gmazlami.gifty.models.user.User

And then down the stacktrace:

java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.LinkedHashMap

The entire stacktrace is posted here.

I looked into some answers referring this error, but those don't seem to apply to my problem, since I'm using Spring-Boot, no xml configs whatsoever.

The affected controller is:

    @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
public ResponseEntity<User> getUser(@PathVariable Long id){
    try{
        return new ResponseEntity<User>(userService.getUserById(id), HttpStatus.OK);
    }catch(NoSuchUserException e){
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

Any help would be greatly appreciated. It is very weird since the exact same things work on other machines perfectly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This happened to me, on one resource only (one method) and I did not understand why. All methods within classes in the same package, with the same annotations, same call to ResponseEntity.ok(...) etc. just worked.

But not this one.

It turns out I had forgottent to generate the getters on my POJO class !

As soon as I had added them it worked.

Hopefully it can save somebody some time eventually...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...