java - no suitable HttpMessageConverter found for response type [class com.avada.rest.UsersController$Users] -


i getting following exception , not sure why...

exception in thread "main" org.springframework.web.client.restclientexception: not extract response: no suitable httpmessageconverter found response type [class com.avada.rest.userscontroller$users] , content type [application/json;charset=utf-8] @ org.springframework.web.client.httpmessageconverterextractor.extractdata(httpmessageconverterextractor.java:109) @ org.springframework.web.client.resttemplate.doexecute(resttemplate.java:576) @ org.springframework.web.client.resttemplate.execute(resttemplate.java:529) @ org.springframework.web.client.resttemplate.getforobject(resttemplate.java:236) @ com.avada.rest.userstest.main(userstest.java:18)

this restcontroller:

@restcontroller @requestmapping("/users") public class userscontroller {      @requestmapping(method = requestmethod.get)     public users getusers() {         users users = new users();         users.setusers(constantshome.userprofilemgr.getusers(null));         return users;     }      @requestmapping(value = "/{id}", method = requestmethod.get)     public user getuser(@pathvariable string id) {         return constantshome.userprofilemgr.getuserbyuserid(id, true, true);     }      public static class users {         private list<user> users = new arraylist<>();          public list<user> getusers() {             return users;         }          public void setusers(list<user> users) {             this.users = users;         }     } } 

this test class:

public class userstest {     private static resttemplate template = new resttemplate();      public static void main (string[] args) throws exception {         // users         string uri = "http://localhost:8080/ir360/rest/users";         userscontroller.users users = template.getforobject(uri, userscontroller.users.class);         system.out.println("looping through users...");         (user user : users.getusers()) {             system.out.println("name=" + user.getname());         }          // 1 user         uri = "http://localhost:8080/ir360/rest/users/admin";         user user = template.getforobject(uri, user.class);         system.out.println("name single user=" + user.getname());     } } 

i can single user no problem if comment out test code "get users".

what doing wrong in code?

p.s. - can make call getusers() through browser , json comes fine know getusers() working...just can't resttemplate work

turned out issue in users class (more user class in list<user>).

i updated user class @jsonignore on fields thought might causing exception , able passed issue.

so others might encounter issue, check object you're trying getforobject on make sure can map fine.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -