[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( ~[camel-core-2.21.1.jar!/:2.21.1]

  at org.apache.camel.processor.RestBindingAdvice.before( ~[camel-core-2.21.1.jar!/:2.21.1]

  at org.apache.camel.processor.RestBindingAdvice.before( ~[camel-core-2.21.1.jar!/:2.21.1]

  at org.apache.camel.processor.CamelInternalProcessor.process( ~[camel-core-2.21.1.jar!/:2.21.1]

  at org.apache.camel.processor.DelegateAsyncProcessor.process( [camel-core-2.21.1.jar!/:2.21.1]

  at org.apache.camel.http.common.CamelServlet.doService( [camel-http-common-2.21.1.jar!/:2.21.1]

  at org.apache.camel.http.common.CamelServlet.service( [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) { = 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?



( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03331.html on line 247
Call Stack
10.0008368728{main}( ).../msg03331.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03331.html on line 247
Call Stack
10.0008368728{main}( ).../msg03331.html:0