As far as I recall CXF 2.7.8 or earlier was not able to pick up newer
Jacksons, you probably need to upgrade to CXF 2.7.13 or 3.0.2
Cheers, Sergey
On 10/11/14 16:21, jkdilunika wrote:
I have configured JacksonJsonProvider to CXF REST server bean. But what I
notice is CXF does not pick the configured JSON provider. It always returns
405 with following warning.
[qtp260261822-13 - /os/v3/token] WARN org.apache.cxf.jaxrs.utils.JAXRSUtils
- No message body reader has been found for request class TokenRequest,
ContentType : application/json.
I have pasted the code blocks I am using. Can some one explain me where have
I gone wrong here?
------------------------------------------------------------------------------------------------------------------------
CXF Server
=========
public void start(){
JAXRSServerFactoryBean serverFactory = new JAXRSServerFactoryBean();
serverFactory.setServiceBean(new IdentityService());
serverFactory.setAddress("http://10.30.9.56:9000/os");
serverFactory.setProviders(Arrays.asList(new
JacksonJsonProvider()));
BindingFactoryManager manager =
serverFactory.getBus().getExtension(BindingFactoryManager.class);
JAXRSBindingFactory factory = new JAXRSBindingFactory();
factory.setBus(serverFactory.getBus());
manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID,
factory);
Server server = serverFactory.create();
LOGGER.info("Server Started on URL http://10.30.9.56:9000/os");
}
Resource Class
=========
@Path("/v3")
public class IdentityService {
@POST
@Path("/token")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createToken(TokenRequest token){
TokenResponse tokenResponse = new
TokenResponse("we54er4564355re645654",
Arrays.asList("identity:http://10.1.2.4:4000","compute:http://10.1.2.4:5000"));
return Response.ok(tokenResponse).build();
}
}
Request POJO
=========
@JsonRootName("tokenRequest")
public class TokenRequest {
private String accessKey;
private String password;
// getters and setters
}
Request Sent
========
POST /v3/token (Content-Type : application/json) { "accessKey": "kasun",
"password": "secret" }
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-REST-Server-does-not-pick-JacksonJsonProvider-tp5750919.html
Sent from the cxf-user mailing list archive at Nabble.com.