NiFi在 JOLT 处理器中引发错误 - 尽管“高级”处理器界面内的测试运行完美!
一些流文件的转换没有错误 - 但大多数都失败了 - 例如:
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
答案 0 :(得分:2)
我无法重现,但我使用的是最新的源代码(在某些时候将成为NiFi 1.2.0),它具有Jolt库的升级以及对JoltTransformJSON处理器的一些更改。我粘贴在上面的JSON和规范中,它转换得很好。
JSON是否使用除Java默认值以外的字符集(通常为UTF-8)传递给JoltTransformJSON?如果是这样,请在JoltTransformJSON处理器之前尝试ConvertCharacterSet处理器。
答案 1 :(得分:1)
和mattyb一样,我也试过这个,也无法重现(使用最新的源代码)。如果您能够捕获失败的内容并发布,以及您正在使用的NiFi版本,我可能至少可以重新创建问题并从那里进行调查。