简体   繁体   English

将数据添加到与PostingFormats相关的Java嵌入式Elasticsearch中的索引时出错

[英]Error while adding data to index in java embedded elasticsearch related to PostingFormats

I am using embedded elasticsearch in java and I am using it as a primary data storage. 我在Java中使用嵌入式Elasticsearch,并将其用作主要数据存储。 But when I am adding data to index it's giving some weird exception 但是,当我向索引添加数据时,出现了一些奇怪的异常

java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.index.codec.postingsformat.PostingFormats.

Versions: Java 1.7, Suse Linux 11, elasticsearch 1.1.0 版本:Java 1.7,Suse Linux 11,elasticsearch 1.1.0

I ran same code on my windows as well as ubuntu, it's running fine there 我在Windows和ubuntu上都运行了相同的代码,在那里运行良好

Following is the exception trace. 以下是异常跟踪。

org.elasticsearch.common.util.concurrent.UncategorizedExecutionException: Failed execution
    at org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at com.iwebezo.indexer.manager.ProductsManager.saveScrapedProductsES(ProductsManager.java:128) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_67]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_67]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.index.codec.postingsformat.PostingFormats
    at org.elasticsearch.index.codec.CodecModule.configurePostingsFormats(CodecModule.java:126) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.index.codec.CodecModule.configure(CodecModule.java:178) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.AbstractModule.configure(AbstractModule.java:60) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.spi.Elements$RecordingBinder.install(Elements.java:204) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.spi.Elements.getElements(Elements.java:85) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.InjectorShell$Builder.build(InjectorShell.java:130) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:99) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.InjectorImpl.createChildInjector(InjectorImpl.java:131) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.inject.ModulesBuilder.createChildInjector(ModulesBuilder.java:69) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.indices.InternalIndicesService.createIndex(InternalIndicesService.java:298) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$2.execute(MetaDataCreateIndexService.java:343) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:308) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:134) ~[uber-indexer-0.0.1-SNAPSHOT.jar:na]
    ... 3 common frames omitted

I actually found answer of this, we are using maven shade plugin to build the JAR and we required to add some of its configurations, we have added following in its pom configurations, 我实际上找到了答案,我们正在使用maven shade plugin构建JAR,我们需要添加一些配置,我们在pom配置中添加了以下内容,

<transformers>
      <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<minimizeJar>false</minimizeJar>

Now its working fine, hope this will be helpful for everybody looking for solution of this problem. 现在它可以正常工作,希望这对寻求该问题解决方案的每个人都将有所帮助。

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

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