title: Apache Camel - response after sending a message to a route
body: <p><br>
  I'm using <code>Apache Camel</code> and <code>Spring Boot</code> for my project. I have the following code where I receive a <code>json object</code> via <code>http</code> on the <code>rtos</code> endpoint; then I map it into a <code>POJO</code>, modify it and send it again to another endpoint.</p>
  
  <pre><code>restConfiguration().component("servlet").host("localhost").port("8080").bindingMode(RestBindingMode.auto);
  
  rest("/request").post("/rtos").type(User.class).to("direct:rtos")
  
  from("direct:rtos").process(new Processor() {
  
    public void process(Exchange exchange) throws Exception {
  
        User body = exchange.getIn().getBody(User.class);
        System.out.println("Input object: " + body.getName() + ", " + body.getAge());
        body.setAge("35");
        System.out.println("Output object: " + body.getName() + ", " + body.getAge());
        }
    }).marshal().json(JsonLibrary.Jackson)
      .to("http4://localhost:8080/receive?bridgeEndpoint=true");
  
  from("servlet:/receive").unmarshal().json(JsonLibrary.Jackson, User.class).process(new Processor() {
      @Override
      public void process(Exchange exchange) throws Exception {
  
      User body = exchange.getIn().getBody(User.class);
      body.setAge("100");
      System.out.println("Received object: " + body.getName() + ", " + body.getAge());
      }
  });
  </code></pre>
  
  <p>This works okay, meaning that the object is correctly manipulated and passed through the endpoints. What happens is that after sending the http request I get <code>500 Internal Server Error</code> and the following error: <br></p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
  </code></pre>
  
  <p>I noticed that the error disappears if I manage to return something to the first route, for example <br></p>
  
  <pre><code>[...]
  .to("http4://localhost:8080/receive?bridgeEndpoint=true").transform().constant("End of route");
  </code></pre>
  
  <p>I wonder why is that, and what it has to do with jackson serialization. And what if I don't want to send a reply to the first request? I red <a href="http://camel.apache.org/request-reply.html" rel="nofollow">this</a> and <a href="http://camel.apache.org/event-message.html" rel="nofollow">this</a>, and I tried to modify my code as follows: <br></p>
  
  <pre><code>from("direct:rtos").setExchangePattern(ExchangePattern.InOnly).process(new Processor() {
  
              public void process(Exchange exchange) throws Exception {
  
                  User body = exchange.getIn().getBody(User.class);
                  System.out.println("Input object: " + body.getName() + ", " + body.getAge());
  
                  body.setAge("35");
                  System.out.println("Output object: " + body.getName() + ", " + body.getAge());
  
  
              }
          }).marshal().json(JsonLibrary.Jackson)
                  .inOnly("http4://localhost:8080/receive?bridgeEndpoint=true");
  </code></pre>
  
  <p>but I get the same error.<br>
  Can anyone suggest me where I'm wrong? I'm trying to understand properly how the Camel flow works, so it's possible that I've made some mistakes somewhere.<br>
  Thanks,<br>
  Sara</p>
  
  <p><em>EDIT</em> this is my User class:</p>
  
  <pre><code>package it.cam.resources;
  
  import com.fasterxml.jackson.annotation.JsonAutoDetect;
  import com.fasterxml.jackson.annotation.JsonProperty;
  import com.fasterxml.jackson.databind.annotation.JsonSerialize;
  import com.fasterxml.jackson.databind.ser.std.StringSerializer;
  
  import java.io.Serializable;
  
  public class User implements Serializable{
  
      @JsonProperty("id")
      private String id;
  
      @JsonProperty("name")
      private String name;
  
      @JsonProperty("age")
      private String age;
  
      @JsonSerialize(using=StringSerializer.class)
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @JsonSerialize(using=StringSerializer.class)
      public String getAge() {
          return age;
      }
  
      public void setAge(String age) {
          this.age = age;
      }
  }
  </code></pre>