简体   繁体   English

NiFi JoltTransformJSON

[英]NiFi JoltTransformJSON

NiFi throws an error in the JOLT processor - although the test inside the "advanced" processor interface works flawlessly! NiFi在JOLT处理器中引发了一个错误-尽管“高级”处理器接口中的测试工作正常!

Some flowfiles are converted without error - the majority however fail - eg: 某些流文件已正确转换,但大多数失败,例如:

JSON: 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" }
      }
    }
  }
]

Did anyone run into this kind of error before? 有人遇到过这种错误吗?

    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

I was unable to reproduce, but I am using the latest source code (which will at some point become NiFi 1.2.0) which has an upgrade of the Jolt library as well as some changes to the JoltTransformJSON processor. 我无法复制,但是我正在使用最新的源代码(有时将成为NiFi 1.2.0),该源代码对Jolt库进行了升级,并对JoltTransformJSON处理器进行了一些更改。 I pasted in the JSON above and the spec, and it converted fine. 我粘贴了上面的JSON和规范,它转换良好。

Is the JSON being passed to JoltTransformJSON using a character set other than the Java default (often UTF-8)? 是否使用Java默认值(通常为UTF-8)以外的字符集将JSON传递给JoltTransformJSON? If so, try a ConvertCharacterSet processor before the JoltTransformJSON processor. 如果是这样,请在JoltTransformJSON处理器之前尝试使用ConvertCharacterSet处理器。

Like mattyb I tried this as well and was also unable to reproduce (using the latest source). 像mattyb一样,我也尝试过此操作,并且也无法复制(使用最新来源)。 If you are able to capture failed content and post , along with the NiFi version you are using, I may be able to at least recreate the problem and investigate from there. 如果您能够捕获失败的内容并发布,以及所使用的NiFi版本,那么我至少可以重现问题并从那里进行调查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM