【发布时间】:2014-10-01 08:48:03
【问题描述】:
尝试使用带有嵌入式 elasticsearch 的 java 创建索引时出现 NoClassDefFoundError。
- Java 1.7 和 Elasticsearch 1.3.2 版本
- 使用 maven 程序集插件构建
- 使用包含所有依赖项的 jar 运行
这是堆栈跟踪的sn-p:-
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)
- 此类包含在弹性搜索的依赖项 jar 中
- 在类路径而不是 jar 上使用已展开的类运行时不会出现此错误。
- 已清除所有以前的快照和类等以避免任何库冲突。
这是否与 elastisearch.jar 中的 META-INF/services 文件夹有关,并且需要使用 maven-shade-plugin
【问题讨论】:
标签: java elasticsearch maven-assembly-plugin