Apache Camel - Read Json from Rest and then convert to Java Object
<p>Currently, my application can </p>

<ol>
<li>Read a json file from local file system</li>
<li>Convert to Java Object using ObjectMapper of Jackson Library</li>
</ol>

<p>Now, I want to change the process to</p>

<ol>
<li>Read a json content from rest endpoint</li>
<li>Log the json content</li>
<li>Convert to Java Object using ObjectMapper of Jackson Library</li>
</ol>

<p>However, I encounter a strange problem that the body in exchange disappear after display. Would like to know what possible setting am I missing?</p>

<p><strong>The XML content</strong></p>

<pre><code>&lt;camelContext id="admin_sysHttpRec_ctx" xmlns="http://camel.apache.org/schema/spring" trace="false"&gt;

    &lt;restConfiguration component="restlet" host="localhost" port="9394"&gt;&lt;/restConfiguration&gt;

    &lt;rest path="/sys"&gt;
        &lt;put uri="/json" id="admin_sysHttpJson_receiver"&gt;
            &lt;to uri="direct:sysJson.process"/&gt;
        &lt;/put&gt;
    &lt;/rest&gt;

    &lt;route id="admin_sysHttpJson_route"&gt;
        &lt;from uri="direct:sysJson.process"/&gt;
        &lt;log message="sysHttpJsonManage BODY: ${body}" loggingLevel="INFO" /&gt;
        &lt;process ref="sysJsonManage"/&gt;
        &lt;transform&gt;
            &lt;constant&gt;Success!&lt;/constant&gt;
        &lt;/transform&gt;
    &lt;/route&gt;

&lt;/camelContext&gt;
</code></pre>

<p><strong>The Processor</strong></p>

<pre><code>@Override
public void process(Exchange exchange) throws Exception {
    LOG.info("body: " + exchange.getIn().getBody(String.class));

    // Setup jsonFileContext
    //      byte[] body = exchange.getIn().getBody(byte[].class);
    String bodyStr = exchange.getIn().getBody(String.class);
    byte[] body = bodyStr.getBytes();
    LOG.info("body.length: " + body.length);
    LOG.info("(String) body.length: " + exchange.getIn().getBody(String.class).length());

    try {
        ObjectMapper objectMapper = new ObjectMapper();
        JsonFileContext jsonFileContext = objectMapper.readValue(body, JsonFileContext.class);
        exchange.setProperty("jsonFileContext", jsonFileContext);
    } catch (Exception e) {
        exchange.setException(e);
    }
}
</code></pre>

<p><strong>Raw payload in http request</strong></p>

<pre><code>{
    "direction":"OUT",
    "srcEncoding":"",
    "destEncoding":""
}
</code></pre>

<p><strong>The result</strong></p>

<pre><code>20160929 15:53:33.193 [Restlet-4844614] INFO admin_sysHttpJson_route - sysHttpJsonManage BODY: {
    "direction":"OUT",
    "srcEncoding":"",
    "destEncoding":""
}
20160929 15:53:33.193 [Restlet-4844614] INFO com.test.admin.sys.http.SysJsonManage - body: 
20160929 15:53:33.194 [Restlet-4844614] INFO com.test.admin.sys.http.SysJsonManage - body.length: 0
20160929 15:53:33.194 [Restlet-4844614] INFO com.test.admin.sys.http.SysJsonManage - (String) body.length: 0
20160929 15:53:33.355 [Restlet-4844614] ERROR org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-XXXXX-61466-1475135595982-0-1 on ExchangeId: ID-XXXXX-61466-1475135595982-0-2). Exhausted after delivery attempt: 1 caught: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
 at [Source: [B@67e6a2; line: 1, column: 1]

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[admin_sysHttpJson_] [admin_sysHttpJson_] [http://localhost:9394/sys/json?restletMethods=PUT                             ] [       181]
[admin_sysHttpJson_] [restBinding1      ] [                                                                              ] [         4]
[admin_sysHttpJson_] [admin_sysHttpJson_] [direct:sysJson.process                                                        ] [       162]
[admin_sysHttpJson_] [log1              ] [log                                                                           ] [         0]
[admin_sysHttpJson_] [process1          ] [ref:sysJsonManage                                                             ] [       160]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
 at [Source: [B@67e6a2; line: 1, column: 1]
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
    at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3781)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3721)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2819)
    at com.test.admin.sys.http.SysJsonManage.process(SysJsonManage.java:31)
    at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
    at org.apache.camel.component.restlet.RestletConsumer$1.handle(RestletConsumer.java:68)
    at org.apache.camel.component.restlet.MethodBasedRouter.handle(MethodBasedRouter.java:54)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:639)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:639)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
    at org.restlet.Component.handle(Component.java:408)
    at org.restlet.Server.handle(Server.java:507)
    at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)
    at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143)
    at org.restlet.engine.connector.HttpServerHelper$1.handle(HttpServerHelper.java:64)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
    at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
    at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
    at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
</code></pre>

<p>The Camel version I am using is 2.17.0</p>