Rollins999
Rollins999

Reputation: 688

Jackson version incompatibility?

I'm in the process of learning REST with Spring. I am using Maven for project dependencies.

I'm using Spring 3.2.1 and Jackson to make GET and POST calls. When I use version 1.5.6 of Jackson, the GET works just fine and I can see the Json version of my object being returned from the GET call. However, when I upgrade to a more recent version of Jackson it no longer works and I get the following returned in the response...

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().

Reviewing other questions on StackOverflow there seems to be issues with the Jackson Mapper and Core versions, but I can find no other references in my project to Jackson so I don't think this is where the problem lies.

The App context contains the following...

    <mvc:annotation-driven/>

<context:component-scan base-package="im.poz.springrestserver" />

and the called method in the controller is as follows...

    @RequestMapping(value = "/clients/{clientid}", method= RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
@ResponseBody

public Client getClient(@PathVariable("clientid") int clientId) throws llegalArgumentException {
    Client client=services.retrieveClientById(clientId);
    return client;
}

@RequestMapping(value = "/clients", method= RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
@ResponseBody
public Client updateClient(@RequestBody Client client) throws IllegalArgumentException {

    client=services.updateClient(client);
    return client;

}

Upvotes: 0

Views: 415

Answers (1)

Rollins999
Rollins999

Reputation: 688

The answer was in the build.

I'm using IntelliJ Idea 11.1 and changes to the Maven POM for the new build do not seem to be reflected in the deployed image, so changing Jackson version meant that Jackson was actually missing completely from the deployed build.

I needed to modify the artifacts and re-deploy.

Problem solved.

Upvotes: 1

Related Questions