[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BindingException: Cannot bind to json as message body is not json compatible.

Hi All,

I am in the process of converting from the Spring XML style Camel configuration to using the Java DSL style, as this seems to be the preferred approach when using Spring Boot. I am trying to create a simple REST POST using org.apache.camel.builder.RouteBuilder but I keep getting the following exception:

org.apache.camel.processor.binding.BindingException: Cannot bind to json as message body is not json compatible. Exchange[ID-Mac-the-Knife-local-1527476025699-0-1]
  at org.apache.camel.processor.RestBindingAdvice.unmarshal(RestBindingAdvice.java:248) ~[camel-core-2.21.1.jar!/:2.21.1]
  at org.apache.camel.processor.RestBindingAdvice.before(RestBindingAdvice.java:128) ~[camel-core-2.21.1.jar!/:2.21.1]
  at org.apache.camel.processor.RestBindingAdvice.before(RestBindingAdvice.java:48) ~[camel-core-2.21.1.jar!/:2.21.1]
  at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:149) ~[camel-core-2.21.1.jar!/:2.21.1]
  at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97) [camel-core-2.21.1.jar!/:2.21.1]
  at org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:208) [camel-http-common-2.21.1.jar!/:2.21.1]
  at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:78) [camel-http-common-2.21.1.jar!/:2.21.1]

for the request:

curl -X POST \
http://localhost:8080/api/candidate/applyx \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"firstName": "Steve",
"lastname": "Hiller"

Here is the code:

public class RestRoute extends RouteBuilder {

  public void configure() 
  throws Exception 


public interface CandidateService {
  void passwordlessApply(Candidate candidate);

public class CandidateServiceImpl implements CandidateService {
  public void passwordlessApply(Candidate candidate) {
    System.out.println("Hello World!");

public class Candidate implements Serializable {

  private static final long serialVersionUID = 1L;

  private String id;
  private String firstName;
  private String lastName;

  public Candidate() {}

  public String getId() {
    return id;

  public void setId(String id) {
    this.id = id;

  public String getFirstName() {
    return firstName;

  public void setFirstName(String firstName) {
    this.firstName = firstName;

  public String getLastName() {
    return lastName;

  public void setLastName(String lastName) {
    this.lastName = lastName;

Seems straightforward enough -- any ideas what I am doing wrong?