Spring Integration LoggingHandler中的NPE

时间:2017-07-26 11:45:36

标签: java spring nullpointerexception spring-integration

我正面临着一些奇怪的NPE,没有org.springframework.integration.handler.LoggingHandler抛出的细节。之前的日志条目是2分钟,之前也很奇怪。

有谁知道背后的原因是什么?

2017-07-25 18:33:38.561 DEBUG o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'markEodPositionsAsProcessedChannel'
2017-07-25 18:35:36.985 ERROR o.s.integration.handler.LoggingHandler   : org.springframework.messaging.MessageHandlingException: nested exception is java.lang.NullPointerException
            at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:96)
            at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:89)
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109)
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
            at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
            at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148)
            at org.springframework.integration.dispatcher.UnicastingDispatcher.access$000(UnicastingDispatcher.java:53)
            at org.springframework.integration.dispatcher.UnicastingDispatcher$3.run(UnicastingDispatcher.java:129)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException

1 个答案:

答案 0 :(得分:1)

您谈到的代码如下:

public T processMessage(Message<?> message) {
    try {
        return this.delegate.process(message);
    }
    catch (Exception e) {
        throw new MessageHandlingException(message, e);
    }
}

显然意味着delegate.process()以某种方式抛出NPE

根据StackTrace,你有一些Service Activator来调用你的POJO服务方法。这看起来就像你的方法已经抛出了NPE

我也相信在Caused by: java.lang.NullPointerException之后StackTrace中还有其他内容。

您在日志中看到ERROR,因为您从某个源开始有一些轮询流 - 入站通道适配器。并且抛出下游的任何异常都会被Poller Ednpoint中的错误处理程序捕获,并以errorChannel作为默认订阅者发送到LoggingHandler

有关详细信息,请参阅Reference Manual