简体   繁体   中英

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. 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

I ran same code on my windows as well as ubuntu, it's running fine there

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,

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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