【发布时间】:2020-02-15 19:55:46
【问题描述】:
我正在尝试在 Adobe Experience Manager 中使用 Java High Level Rest Client 来完成 Lucene、Solr 和 Elasticsearch 搜索引擎之间的比较项目。
我在 elasticsearh 实施方面遇到了一些问题。 代码如下:
-
父pom.xml中的依赖(在核心pom.xml中定义相同)
<!-- Elasticseach dependencies --> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.4.0</version> </dependency> -
我使用的唯一一行代码来自上面的依赖项
try (RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(server, port, protocol), new HttpHost(server, secondPort, protocol)));) { } catch (ElasticsearchException e) { LOG.error("Exception: " + e); }
protocol = "http", server = "localhost", port = 9200, secondPort = 9201
- 错误
- 来自 IntelliJ 的依赖项
我知道依赖版本通常存在问题,但在这种情况下都是 7.4.0。 elasticsearch 7.4.0v 也在 3 个节点上本地运行。
这个项目是在 We.Retail 项目上完成的,因此很容易复制。此外,所有出现此错误的代码都可以在此处获得: https://github.com/tadijam64/search-engines-comparison-on-we-retail/tree/elasticsearch-integration AEM 6.4v。
感谢任何信息或想法。
更新 我尝试添加以下内容以在外部嵌入这些依赖项,因为它们不是 OSGi 依赖项:
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>org.apache.servicemix.bundles.solr-solrj, log4j, noggit, zookeeper,
elasticsearch-rest-high-level-client
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Export-Package>we.retail.core.model*</Export-Package>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Private-Package>we.retail.core*</Private-Package>
<Sling-Model-Packages>
we.retail.core.model
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
错误仍然存在。我也尝试将其添加到“导出包”中,但没有任何帮助。
通过Elasticsearch documentation,我只需要使用 Elasticsearch 就可以了
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.4.0</version>
</dependency>
但随后 NoClassDefFoundErrors 发生。这似乎是传递依赖的问题。不确定,但任何想法都值得赞赏。
其他一些建议可以在这里找到:https://forums.adobe.com/thread/2653586
我也尝试过添加它的传递依赖项,例如 org.elasticsearch 和 org.elasticsearch.client,但它不起作用。同样的错误,只是其他类。
AEM 版本 6.4,Java 版本:jdk1.8.0_191.jdk
【问题讨论】:
-
在 AEM System Console 捆绑包中,您是否看到任何与弹性搜索相关的依赖项?
-
仅在清单头和捆绑类路径下,也应该在其他地方吗?
-
我认为清单会有一些导入条目等。实际的依赖关系不存在。我认为 AEM 不提供弹性搜索,这可能就是您收到 Class Not Found 异常的原因。依赖需要Embedded or separately installed as OSGi bundle
-
试过了,手动安装了 ES rest 高级客户端和 org.elasticsearch 依赖项并添加为依赖项,但现在我有类似的:“java.lang.NoClassDefFoundError: org/elasticsearch/common/xcontent/DeprecationHandler "
标签: maven elasticsearch osgi aem elasticsearch-api