Исключение NullPointer в Apache Camel - PullRequest
0 голосов
/ 24 августа 2018

В одном из моих проектов у меня была проблема, которая не всегда воспроизводима, но снова и снова создает проблемы. Я объясню важные части здесь:

Этот проект развертывается в Apache Karaf.

Первый маршрут:

...
...
.to("prs-producer:queue:raw.token.passes")

Второй путь: Входящие данные с шага 1 имеют зависимости, поэтому необходимо их обогащать во время полета.

from("prs-consumer:queue:raw.token.passes")
      .enrich("dw:SELECT TOP 1 Id FROM base.Orders WHERE SourceId = :#OrderId?outputType=SelectOne", new DependencyAggregationStrategy("OrderId"))
      .enrich("dw:SELECT TOP 1 Id FROM base.Campaigns WHERE SourceId = :#CampaignId?outputType=SelectOne", new DependencyAggregationStrategy("CampaignId"))

Первый и второй маршруты развернуты в виде разных файлов jar в Karaf.

Из второго маршрута видно, что этот предмет зависит от Приказов и Кампаний. Таким образом, развертывание этого маршрута перед этими банками (маршрутами) приводит к следующей ошибке.

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route9            ] [route9            ] [prseai-consumer://queue:raw.token.passes                                   ] [         2]
[route9            ] [enrich7           ] [enrich[constant{prsdw:SELECT TOP 1 Id FROM base.SourceTable WHERE SourceId = ] [         1]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Entry
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | CamelInternalProcessor           | 50 - org.apache.camel.camel-core - 2.21.2 | Exchange processed and is continued routed synchronously for exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 -> Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | Pipeline                         | 50 - org.apache.camel.camel-core - 2.21.2 | Processing exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 is continued being processed synchronously
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Returning 5 fields
2018-08-22T23:14:14,006 | DEBUG | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | Pipeline                         | 50 - org.apache.camel.camel-core - 2.21.2 | Message exchange has failed: so breaking out of pipeline for exchange: Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451] Exception: java.lang.NullPointerException
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | Pipeline                         | 50 - org.apache.camel.camel-core - 2.21.2 | Processing complete for exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 >>> Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Exit
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | DefaultUnitOfWork                | 50 - org.apache.camel.camel-core - 2.21.2 | UnitOfWork afterRoute: route9 for ExchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 with Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | CamelInternalProcessor           | 50 - org.apache.camel.camel-core - 2.21.2 | route: Recording duration: 2 millis for exchange: Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Printing 5 fields
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | DefaultUnitOfWork                | 50 - org.apache.camel.camel-core - 2.21.2 | UnitOfWork done for ExchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 with Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Exit returning descriptorType=operation, displayName=suspend, mask=false, name=suspend, role=operation
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EventHelper                      | 50 - org.apache.camel.camel-core - 2.21.2 | Notifier: org.apache.camel.core.osgi.OsgiCamelContextPublisher@3e78b77b is not enabled for the event: ID-brckner-ThinkPad-T480-1534972104151-2-451 exchange failure: Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451] cause java.lang.NullPointerException
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | CamelInternalProcessor           | 50 - org.apache.camel.camel-core - 2.21.2 | Exchange processed and is continued routed synchronously for exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 -> Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | MBeanInfoAssembler               | 50 - org.apache.camel.camel-core - 2.21.2 | Assembled operation: ModelMBeanOperationInfo: suspend ; Description: Suspend Service ; Descriptor: descriptorType=operation, displayName=suspend, mask=false, name=suspend, role=operation ; ReturnType: void ; Signature: 
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EndpointMessageListener          | 50 - org.apache.camel.camel-core - 2.21.2 | onMessage.process END
2018-08-22T23:14:14,007 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EndpointMessageListener          | 50 - org.apache.camel.camel-core - 2.21.2 | onMessage END throwing exception: java.lang.NullPointerException
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Constructor
2018-08-22T23:14:14,007 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | BundleDelegatingClassLoader      | 48 - org.apache.camel.camel-blueprint - 2.21.2 | LoadClass: org.apache.camel.component.jms.EndpointMessageListener, resolve: false
2018-08-22T23:14:14,007 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | BundleDelegatingClassLoader      | 48 - org.apache.camel.camel-blueprint - 2.21.2 | FindClass: org.apache.camel.component.jms.EndpointMessageListener
2018-08-22T23:14:14,007 | DEBUG | Blueprint Event Dispatcher: 1 | modelmbean                       |  -  -  | Null Descriptor, creating new.
2018-08-22T23:14:14,007 | WARN  | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EndpointMessageListener          | 50 - org.apache.camel.camel-core - 2.21.2 | Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.lang.NullPointerException]
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830) ~[50:org.apache.camel.camel-core:2.21.2]
    at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:196) ~[51:org.apache.camel.camel-jms:2.21.2]
    at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:117) ~[51:org.apache.camel.camel-jms:2.21.2]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) ~[106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NullPointerException

И, как я уже сказал, эта ошибка не всегда воспроизводима. Кто-нибудь сталкивался с такими проблемами в прошлом или настоящем? Было бы здорово получить некоторые указания по этому вопросу.

edit - дополнительные журналы:

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route42           ] [route42           ] [prseai-consumer://queue:raw.token.passes                                   ] [         0]
[route42           ] [enrich21          ] [enrich[constant{prsdw:SELECT TOP 1 Id FROM base.Orders WHERE SourceId = ] [         0]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null
2018-08-19T17:41:19,576 | WARN  | Camel (prseai-passes-staging-producer) thread #48 - JmsConsumer[raw.token.passes] | EndpointMessageListener          | 50 - org.apache.camel.camel-core - 2.20.3 | Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.lang.NullPointerException]
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1831) ~[50:org.apache.camel.camel-core:2.20.3]
    at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:195) ~[51:org.apache.camel.camel-jms:2.20.3]
    at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:116) ~[51:org.apache.camel.camel-jms:2.20.3]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) ~[106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NullPointerException
2018-08-19T17:41:19,576 | ERROR | Camel (prseai-passes-staging-producer) thread #48 - JmsConsumer[raw.token.passes] | DefaultErrorHandler              | 50 - org.apache.camel.camel-core - 2.20.3 | Failed delivery for (MessageId: ID-brckner-ThinkPad-T480-1534693238999-33-43460 on ExchangeId: ID-brckner-ThinkPad-T480-1534693238999-33-43459). Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException

Мы используем Active MQ 5.15.3 и Camel 2.20.3. Спасибо, Cooshal.

...