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

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

Never-mind folks, some judicious debugging through the camel code revealed that I did not have the required jar for unmarshalling the JSON. Adding compile group: 'org.apache.camel', name: 'camel-jackson', version: '2.21.1' to my gradle fixed the issue.

On Monday, May 28, 2018 6:42 PM, Steve Hiller <shetc@xxxxxxxxxxxxx> wrote:

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?