You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Tadija (Jira)" <ji...@apache.org> on 2019/11/01 20:03:00 UTC
[jira] [Created] (FELIX-6198) Problem with ebmeding elasticsearch
dependency
Tadija created FELIX-6198:
-----------------------------
Summary: Problem with ebmeding elasticsearch dependency
Key: FELIX-6198
URL: https://issues.apache.org/jira/browse/FELIX-6198
Project: Felix
Issue Type: Bug
Components: Maven Bundle Plugin
Affects Versions: maven-bundle-plugin-4.2.1
Environment: Adobe Experience Manager 6.4, Java 1.8 (tried on 9 and 11 as well), elasticsearch version 7.4.1
Reporter: Tadija
Attachments: Screenshot 2019-10-30 at 09.54.56.png, Screenshot 2019-11-01 at 20.36.09.png
I am trying to embed the following dependency and it's transitive dependencies:
{code:java}
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</dependency>{code}
I am working with AEM 6.4v and tried maven-bundle-plugin versions 2.1.0 and 4.2.1.
With first version, I can not build project due to the following error:
Classes found in the wrong directory: elasticsearch/META-INF/versions/9/org/elasticsearch/monitor/jvm
I've also tried two options of maven-bundle plugin which are showed bellow:
With maven hade plugin:
{code:java}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.elasticsearch.client:elasticsearch-rest-high-level-client</include>
<include>org.elasticsearch:elasticsearch</include>
<include>org.elasticsearch.client:elasticsearch-rest-client</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>org.elasticsearch.client:elasticsearch-rest-high-level-client</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>org.elasticsearch:elasticsearch</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>org.elasticsearch.client:elasticsearch-rest-client</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
</filters>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<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>
<!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
<_removeheaders>Ignore-Package,Include-Resource,Private-Package,Embed-Dependency</_removeheaders>
</instructions>
<unpackBundle>true</unpackBundle>
</configuration>
</plugin>{code}
Second without maven shade plugin:
{code:java}
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>
org.apache.servicemix.bundles.solr-solrj, noggit,
*elasticsearch*, rank-eval-client, lang-mustache-client,
httpasyncclient, mapper-extras-client, parent-join-client,
aggs-matrix-stats-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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>
*.impl
</excludePackageNames>
</configuration>
</plugin>
{code}
Dependencies:
{code:java}
<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.4.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.4.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.4.1</version>
</dependency>
{code}
Also I got this warning all the time in IntelliJ - *The package org.elasticsearch.client is inside a non-bundle dependency* on this code:
try (RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(server, port, protocol),//
new HttpHost(server, secondPort, protocol))); ResourceResolver resourceResolver = request.getResourceResolver())
{
if (indexType.equalsIgnoreCase(PROP_INDEX_TYPE_INDEX))
{
Session session = resourceResolver.adaptTo(Session.class);
XContentBuilder builder = this.elasticsearchService.crawlContent(session);
IndexRequest indexRequest = new IndexRequest(indexName);
indexRequest.id("2");
try
{
indexRequest.source(builder);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
writeResponse(indexResponse, response);
}
*So problem is sometimes shown as NoClassDefinition for come of transitive dependencies, and sometimes servlet returns 500 error if any of elasticsearch imports are inside the code.*
Any idea/help will be appreciated.
Whis is done on [we.retail|[https://github.com/Adobe-Marketing-Cloud/aem-sample-we-retail]] project so it is easy replicable. You can see full code on the following links:
[https://github.com/tadijam64/search-engines-comparison-on-we-retail/blob/elasticsearch-servlet-impl/core/pom.xml]
and other version here:
[https://github.com/tadijam64/search-engines-comparison-on-we-retail/blob/elasticsearch-maven-shade-test/core/pom.xml]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)