gpt4 book ai didi

运行 Logstash 插件时出现 java.lang.NoSuchMethodError

转载 作者:行者123 更新时间:2023-12-02 01:51:06 27 4
gpt4 key购买 nike

我有一个java程序,可以将数据转换为JSON格式。我能够成功地将程序构建为 jar 文件,并在独立程序中成功使用该 jar 的功能。

我为 Logstash 创建了一个 jruby 插件,它调用这个 jar。运行 Logstash 时:

gem build logstash-filter-example.gemspec &&
../../logstash-5.6.7.freshinstall/bin/logstash-plugin install logstash-filter-example-0.1.1.gem &&
../../logstash-5.6.7.freshinstall/bin/logstash -e 'input { stdin{} } filter { example {} } output {stdout { codec => rubydebug }}'

我收到以下错误:

/dataservice/DataServiceClient.java:156:in `parseQueryRowEntry': java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.node.JsonNodeFactory.numberNode(Ljava/math/BigDecimal;)Lcom/fasterxml/jackson/databind/node/NumericNode;
from com/mike/dataservice/DataServiceClient.java:93:in `toJsonObject'
from com/mike/dataservice/DataServiceClient.java:66:in `getData'
from java/lang/reflect/Method.java:498:in `invoke'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/vendor/local_gems/ecdbfdf7/logstash-filter-example-0.1.1/lib/logstash/filters/example.rb:49:in `filter'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filters/base.rb:145:in `do_filter'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filters/base.rb:164:in `multi_filter'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filters/base.rb:164:in `multi_filter'
from org/jruby/RubyArray.java:1613:in `each'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filters/base.rb:161:in `multi_filter'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filters/base.rb:161:in `multi_filter'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filter_delegator.rb:46:in `multi_filter'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/filter_delegator.rb:46:in `multi_filter'
from (eval):42:in `filter_func'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/pipeline.rb:398:in `filter_batch'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/pipeline.rb:398:in `filter_batch'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/pipeline.rb:379:in `worker_loop'
from /Users/michael.dobrin/compilationsFromSource/logstash-5.6.7/logstash-5.6.7.freshinstall/logstash-core/lib/logstash/pipeline.rb:342:in `start_workers'
from java/lang/Thread.java:748:in `run'

由于某种原因,无法识别 numberNode() 方法。然而,当使用独立的 jruby 程序运行我的 jar 时,即使使用 Logstash 本地安装的 jruby 实例,也没有问题。此外,该程序成功使用了我的 jar 文件中的一些方法... numberNode(Ljava/math/BigDecimal;) 是唯一无法识别的方法。为什么 Logstash 看不到这个?

最佳答案

很可能 Logstash 添加了 JsonNodeFactory到与您的应用程序期望的版本不兼容的类路径。该方法围绕 jackson-databind-2.10 进行了重构。

您可以通过检查类的加载位置来验证它。例如。 System.out.println(JsonNodeFactory.class.getProtectionDomain().getCodeSource().getLocation());

关于运行 Logstash 插件时出现 java.lang.NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57425759/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com