no suitable HttpMessageConverter found for response type
Hello,
I get this exception on the Android site using RestTemplate.
Caused by: org.springframework.web.client.RestClientException : Could not extract response: no suitable HttpMessageConverter found for response type [com.tck.gia.resthome.shared.dto.MenuDTO] and content type [application/xml]
The servercode is like this(Controller):
Code:
@RequestMapping(value = "/menu", method = RequestMethod.GET)
@ResponseBody
public MenuDTO findMenu() {
Menu menu = restService.findActiveMenu();
if (menu != null) {
return menu.getMenuDTO();
}
return null;
}
What is the default marshaller?
On my android app I use this code:
Code:
url = new URI(StartUp.GIA_SERVER_URL + "/GiaRestHome/rest/menu/");
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
restTemplate.getMessageConverters().add(new FormHttpMessageConverter());
menuDTO = restTemplate.getForObject(url, MenuDTO.class);
I don't understand wich default converter is used. When I go directly to the browser I see this:
HTML Code:
<com.tck.gia.resthome.shared.dto.MenuDTO>
<id>1</id>
<description>TestMenu</description>
<activated>true</activated>
<enabled>true</enabled>
<mainCategories>
<com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
<id>1</id>
<description>Lunch</description>
<subCategories>
<com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
<id>1</id>
<description>Vegetarisch</description>
<dishes>
<com.tck.gia.resthome.shared.dto.MenuDishDTO>
<id>1</id>
<description>Bloemkool</description>
</com.tck.gia.resthome.shared.dto.MenuDishDTO>
<com.tck.gia.resthome.shared.dto.MenuDishDTO>
<id>2</id>
<description>Sla</description>
</com.tck.gia.resthome.shared.dto.MenuDishDTO>
</dishes>
</com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
</subCategories>
</com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
<com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
<id>2</id>
<description>Diner</description>
<subCategories>
<com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
<id>2</id>
<description>Vlees</description>
<dishes>
<com.tck.gia.resthome.shared.dto.MenuDishDTO>
<id>3</id>
<description>Biefstuk</description>
</com.tck.gia.resthome.shared.dto.MenuDishDTO>
</dishes>
</com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
</subCategories>
</com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
</mainCategories>
</com.tck.gia.resthome.shared.dto.MenuDTO>