Camel Exchange 上的 NullPointerException 试图获取正文

NullPointerException on Camel Exchange trying to get body

我正在尝试设置服务总线。我尝试创建的第一个服务应该将 SOAP 转换为 JSON。我已经创建了一个端点和一个 WSDL 都测试成功。当我尝试将消息转换为程序 returns 一个 NullPointerException。

我在处理函数中输出了以下数据:

交换 [ID-91a89d0e303b-36665-1571915569757-0-2][消息:[com.example.UpsertItemRequest@6a8344b9]]

Exchange.getIn() 消息:[com.example.UpsertItemRequest@6a8344b9]

Exchange.getIn().getBody(String.class) upsertItem 抛出异常,现在展开 org.apache.cxf.interceptor.Fault: 空指针异常

applicationcontext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xmlns:osgi="http://www.springframework.org/schema/osgi"
   xmlns:cxf="http://camel.apache.org/schema/cxf"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf-2.8.3.xsd">

<cxf:cxfEndpoint id="upsertItemCxfEndpoint"
    address="/pimcore/upsertItem"
    endpointName="a:upsertItemEndpoint"
    serviceName="a:upsertItemService"
    wsdlURL="wsdl/upsert-item.wsdl"
    serviceClass="com.example.UpsertItemEndpoint"
    xmlns:a="http://example.com"/>

<bean id="upsertItemTransformer" class="com.example.esb.UpsertItemTransformer"/>

<bean id="upsertItemLogger" class="com.example.esb.UpsertItemLogger"/>

<camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
    <route id="upsertItem">
        <from uri="cxf:bean:upsertItemCxfEndpoint" />
        <process ref="upsertItemLogger" />
        <process ref="upsertItemTransformer" />
    </route>
</camelContext>

UpsertItemTransformer.java

package com.example.esb;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class UpsertItemTransformer implements Processor {
    public void process(Exchange exchange) throws Exception {
        String body = exchange.getIn().getBody(String.class);
        exchange.getOut().setBody(body.toLowerCase());
    }
}

myPost.xml

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:upsertItemRequest xmlns:ns1='http://example.com'>
      <ItemCode>12345</ItemCode>
      </ns1:upsertItemRequest>
  </s11:Body>
</s11:Envelope>

堆栈跟踪

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException
    at com.example.esb.UpsertItemTransformer.process(UpsertItemTransformer.java:9)[222:com.example.sap_pimcore_product:1.0.0.SNAPSHOT]
    at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.asyncInvoke(CxfConsumer.java:154)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.invoke(CxfConsumer.java:133)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.run(ServiceInvokerInterceptor.java:59)[57:org.apache.cxf.cxf-core:3.1.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_222]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_222]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.run(ServiceInvokerInterceptor.java:126)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:252)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:299)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:218)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)[17:javax.servlet-api:3.1.0]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:274)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[186:org.eclipse.jetty.security:9.2.19.v20160908]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.Server.handle(Server.java:499)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:544)[179:org.eclipse.jetty.io:9.2.19.v20160908]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[190:org.eclipse.jetty.util:9.2.19.v20160908]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)[190:org.eclipse.jetty.util:9.2.19.v20160908]
    at java.lang.Thread.run(Thread.java:748)[:1.8.0_222]
2019-10-24 11:12:54,271 | WARN  | tp1559046516-107 | PhaseInterceptorChain            | 57 - org.apache.cxf.cxf-core - 3.1.9 | Application {http://example.com}upsertItemService#{http://example.com}upsertItem has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: NullPointerException
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.checkFailure(CxfConsumer.java:301)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.setResponseBack(CxfConsumer.java:275)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.asyncInvoke(CxfConsumer.java:169)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.invoke(CxfConsumer.java:133)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.run(ServiceInvokerInterceptor.java:59)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:278)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:252)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:299)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:218)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)[17:javax.servlet-api:3.1.0]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:274)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[186:org.eclipse.jetty.security:9.2.19.v20160908]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.Server.handleAsync(Server.java:549)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:318)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:544)[179:org.eclipse.jetty.io:9.2.19.v20160908]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[190:org.eclipse.jetty.util:9.2.19.v20160908]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)[190:org.eclipse.jetty.util:9.2.19.v20160908]
    at java.lang.Thread.run(Thread.java:748)[:1.8.0_222]
Caused by: java.lang.NullPointerException
    at com.example.esb.UpsertItemTransformer.process(UpsertItemTransformer.java:9)[222:com.example.sap_pimcore_product:1.0.0.SNAPSHOT]
    at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.asyncInvoke(CxfConsumer.java:154)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.invoke(CxfConsumer.java:133)[44:org.apache.camel.camel-cxf:2.16.5]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.run(ServiceInvokerInterceptor.java:59)[57:org.apache.cxf.cxf-core:3.1.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_222]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_222]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.run(ServiceInvokerInterceptor.java:126)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)[57:org.apache.cxf.cxf-core:3.1.9]
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:252)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:299)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:218)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)[17:javax.servlet-api:3.1.0]
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:274)[82:org.apache.cxf.cxf-rt-transports-http:3.1.9]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[186:org.eclipse.jetty.security:9.2.19.v20160908]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[188:org.eclipse.jetty.servlet:9.2.19.v20160908]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[211:org.ops4j.pax.web.pax-web-jetty:4.3.0]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.Server.handle(Server.java:499)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[187:org.eclipse.jetty.server:9.2.19.v20160908]
    ... 5 more

我猜 NPE 不是来自读取正文,而是来自访问输出消息正文。

在 Camel 中,out 消息通常不存在。 If it is not present, Camel automatically uses the in message

因此,强烈推荐 Camel 最佳做法是单独保留输出消息,只更新输入消息。当然也有一些特殊的例外,但你会在需要的时候发现它们。

所以改为这样做

public void process(Exchange exchange) throws Exception {
    String body = exchange.getIn().getBody(String.class);
    exchange.getIn().setBody(body.toLowerCase());
}

顺便说一句:处理器接口的使用和测试相当笨拙。请改用 POJO!