I'm trying to run the hateoas spring boot example located at https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-hateoas (I'm trying to run Version 1.2.6.RELEASE).
When accessing the customers service provided by the example I get a MarshalException:
Could not marshal [Resources { content: [sample.domain.Customer@72c01d5a, sample.domain.Customer@5ef1ebf9, sample.domain.Customer@237de11a], links: [http://localhost:8080/customers;rel="self"] }]: null; nested exception is javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.internal.SAXException2: class sample.domain.Customer nor any of its super class is known to this context. javax.xml.bind.JAXBException: class sample.domain.Customer nor any of its super class is known to this context.]
This is caused by the following code:
@RequestMapping(method = RequestMethod.GET)
HttpEntity<Resources<Customer>> showCustomers() {
Resources<Customer> resources = new Resources<Customer>(this.repository.findAll());
resources.add(this.entityLinks.linkToCollectionResource(Customer.class));
return new ResponseEntity<Resources<Customer>>(resources, HttpStatus.OK);
}
While I could probably implement my own
public class CustomerResources extends Resources<Customer> {
I'd like to avoid this if at all possible.
Also if it has to be like this I'm confused why it's not like this in the example. Am I missing something? How can I get the sample to work?
Thanks in advance!