NiFi在JOLT處理器中拋出錯誤,儘管「高級」處理器接口內的測試完美無瑕!NiFi JoltTransformJSON
一些flowfiles轉換沒有錯誤 - 但多數失敗 - 比如:
JSON:
{
"abc": {
"HEADER": {
"A": "WDD2132041A2213962",
"B": "75268508"
},
"BODY": {
"C": "OK",
"D": "1"
},
"ABCDEFG": "Time[s] | X | Y | Z | A/B [%] | X/Y [%] "
}
}
JOLT:
[
{
"operation": "shift",
"spec": {
"abc": {
"HEADER": { "*": "&" },
"SUMMARY": { "*": "&" },
"*": { "$": "ITEM", "@": "VAL" }
}
}
}
]
沒有人碰到這樣那樣的錯誤之前?
2017-03-24 15:12:35,765 ERROR [Timer-Driven Process Thread-6] o.a.n.p.standard.JoltTransformJSON
java.lang.RuntimeException: Unable to load JSON object from InputStream.
at com.bazaarvoice.jolt.JsonUtilImpl.jsonToObject(JsonUtilImpl.java:105) ~[json-utils-0.0.21.jar:0.0.21]
at com.bazaarvoice.jolt.JsonUtils.jsonToObject(JsonUtils.java:117) ~[json-utils-0.0.21.jar:0.0.21]
at org.apache.nifi.processors.standard.JoltTransformJSON.onTrigger(JoltTransformJSON.java:244) ~[nifi-standard-processors-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) [nifi-api-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1099) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:136) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:132) [nifi-framework-core-1.1.0.2.1.1.0-2.jar:1.1.0.2.1.1.0-2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_77]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_77]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_77]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.ArrayIndexOutOfBoundsException) (through reference chain: java.util.LinkedHashMap["xml"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.deser.std.ContainerDeserializerBase.wrapAndThrow(ContainerDeserializerBase.java:88) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringMap(MapDeserializer.java:507) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:341) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.deserialize(UntypedObjectDeserializer.java:220) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3702) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2784) ~[jackson-databind-2.6.1.jar:2.6.1]
at com.bazaarvoice.jolt.JsonUtilImpl.jsonToObject(JsonUtilImpl.java:102) ~[json-utils-0.0.21.jar:0.0.21]
... 14 common frames omitted
我相信堆棧跟蹤表明處理器無法從您的流文件中讀取JSON。失敗的流文件的實際內容與上面粘貼到高級UI中的內容有何不同? – James
內容中有特殊字符 - 例如'「1.0 | 2.0 | 3.0」'但在裏面「」 – Daniel
您可以通過使用不同的NiFi處理器或解析JSON的外部工具加載它來檢查它是否爲格式正確的JSON? EvaluateJsonPath可能工作。 – James