我在java中使用嵌入式elasticsearch,我将它用作主数据存储。但是当我添加数据来索引时,它会给出一些奇怪的异常
java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.index.codec.postingsformat.PostingFormats.
版本:Java 1.7,Suse Linux 11,elasticsearch 1.1.0
我在我的窗口和ubuntu上运行相同的代码,它在那里运行良好
以下是异常追踪。
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
答案 0 :(得分:1)
我实际上找到了答案,我们正在使用maven shade插件来构建JAR,我们需要添加一些配置,我们在其pom配置中添加了以下内容,
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<minimizeJar>false</minimizeJar>
现在它的工作正常,希望这对每个寻求解决这个问题的人都有帮助。