ServiceConfigurationError: Cannot instantiate SPI class: org.apache.lucene.codecs.compressing.FastCompressingCodec

ServiceConfigurationError: Cannot instantiate SPI class: org.apache.lucene.codecs.compressing.FastCompressingCodec

我正在尝试 运行 通过使用 elasticsearch 7.7.1 扩展 ESSingleNodeTestCase 进行测试。但我收到以下错误。我没有看到任何 jar hell 错误,并且我已经按照提到的方式进行了 intellij 设置 here

java.util.ServiceConfigurationError: Cannot instantiate SPI class: org.apache.lucene.codecs.compressing.FastCompressingCodec

    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:82)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:51)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:38)
    at org.apache.lucene.codecs.Codec$Holder.<clinit>(Codec.java:47)
    at org.apache.lucene.codecs.Codec.getDefault(Codec.java:143)
    at org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.before(TestRuleSetupAndRestoreClassEnv.java:142)
    at org.apache.lucene.util.AbstractBeforeAfterRule.evaluate(AbstractBeforeAfterRule.java:44)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.util.TestRuleStoreClassName.evaluate(TestRuleStoreClassName.java:41)
    at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
    at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.util.TestRuleAssertionsRequired.evaluate(TestRuleAssertionsRequired.java:53)
    at org.apache.lucene.util.TestRuleMarkFailure.evaluate(TestRuleMarkFailure.java:47)
    at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures.evaluate(TestRuleIgnoreAfterMaxFailures.java:64)
    at org.apache.lucene.util.TestRuleIgnoreTestSuites.evaluate(TestRuleIgnoreTestSuites.java:54)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:368)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: blockSize must be in 2-22, got 1024
    at org.apache.lucene.codecs.compressing.CompressingStoredFieldsFormat.<init>(CompressingStoredFieldsFormat.java:114)
    at org.apache.lucene.codecs.compressing.CompressingCodec.<init>(CompressingCodec.java:96)
    at org.apache.lucene.codecs.compressing.FastCompressingCodec.<init>(FastCompressingCodec.java:24)
    at org.apache.lucene.codecs.compressing.FastCompressingCodec.<init>(FastCompressingCodec.java:31)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:72)
    ... 20 more

然后

REPRODUCE WITH: ./gradlew 'null' --tests "com.vnera.query.runner.MyTest" -Dtests.seed=5351B8690E63EDD8 -Dtests.locale=en-IN -Dtests.timezone=Asia/Kolkata
NOTE: Mac OS X 10.15.6 x86_64/Azul Systems, Inc. 1.8.0_242 (64-bit)/cpus=8,threads=1,free=237421568,total=324534272

java.lang.NullPointerException
    at java.util.Objects.requireNonNull(Objects.java:203)
    at org.apache.lucene.codecs.Codec.setDefault(Codec.java:154)
    at org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.after(TestRuleSetupAndRestoreClassEnv.java:279)
    at org.apache.lucene.util.AbstractBeforeAfterRule.evaluate(AbstractBeforeAfterRule.java:51)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.util.TestRuleStoreClassName.evaluate(TestRuleStoreClassName.java:41)
    at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
    at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at org.apache.lucene.util.TestRuleAssertionsRequired.evaluate(TestRuleAssertionsRequired.java:53)
    at org.apache.lucene.util.TestRuleMarkFailure.evaluate(TestRuleMarkFailure.java:47)
    at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures.evaluate(TestRuleIgnoreAfterMaxFailures.java:64)
    at org.apache.lucene.util.TestRuleIgnoreTestSuites.evaluate(TestRuleIgnoreTestSuites.java:54)
    at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
    at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:368)
    at java.lang.Thread.run(Thread.java:748)

谁能告诉我是什么原因造成的,我该如何解决?

问题是因为我使用了不同版本的 elasticsearch-test 框架和 elasticsearch

<dependency>
       <groupId>org.elasticsearch.test</groupId>
       <artifactId>framework</artifactId>
       <version>7.6.0</version>
       <scope>test</scope>
</dependency>

<dependency>
       <groupId>org.elasticsearch</groupId>
       <artifactId>elasticsearch</artifactId>
       <version>7.7.1</version>
</dependency>

问题已通过将 org.elasticsearch.test:framework 也设为 7.7.1

来解决