Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Elasticsearch third arty dependency in AEM

Avatar

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile
tadijam47062732
Level 2

24-10-2019

I am having some problems using elasticsearch-rest-high-level-client dependency in my project.

According to Elasticsearch documentation only this should be included:

<dependency>
  <groupId>org.elasticsearch.client</groupId>
  <artifactId>elasticsearch-rest-high-level-client</artifactId>
  <version>7.4.0</version>
</dependency>

However, there were many NoClassDefinitionFound errors, so I embed the package inside maven-bundle-plugin. I realized that no transitive dependencies are included (altho I have   <Embed-Transitive>true</Embed-Transitive>)
so I've added many of them like this:

<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-rest-high-level-client,

  elasticsearch,

  elasticsearch-core,

  elasticsearch-rest-client,

  elasticsearch-x-content,

  elasticsearch-core,

  elasticsearch-secure-sm,

  rank-eval-client,

  lang-mustache-client,

  httpasyncclient,

  lucene-core;

   </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>
  <_fixupmessages>"Classes found in the wrong directory";is:=warning</_fixupmessages>
  </instructions>
  </configuration>
</plugin>

Now I have problem while indexing content: Method threw 'java.lang.NoClassDefFoundError' exception. Cannot evaluate org.elasticsearch.action.index.IndexRequest.toString()

So some other dependencies are missing or org.elasticsearch is not properly imported.

Is there a better way to do this? I've seen some with creating bundle with third party dependencies (using Eclipse to create plugin as standard OSGi package), but I am not sure how then to include that dependencies in main (core) bundle. Any other recommendation?

Note:

  <_fixupmessages>"Classes found in the wrong directory";is:=warning</_fixupmessages>

This was needed because when I add elasticsearch artifactid in Embed-package I can not run code because of this error:

[ERROR] Bundle com.adobe.cq.sample:we.retail.core:bundle:3.0.0-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/9/org/elasticsearch/monitor/jvm/JvmPid.class=org.elasticsearch.monitor.jvm.JvmPid}

[ERROR] Bundle com.adobe.cq.sample:we.retail.core:bundle:3.0.0-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/9/org/elasticsearch/core/internal/io/Streams.class=org.elasticsearch.core.internal.io.Streams}

[ERROR] Bundle com.adobe.cq.sample:we.retail.core:bundle:3.0.0-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/9/org/apache/lucene/util/LongsRef.class=org.apache.lucene.util.LongsRef, META-INF/versions/9/org/apache/lucene/search/PointRangeQuery$1.class=org.apache.lucene.search.PointRangeQuery$1, META-INF/versions/9/org/apache/lucene/util/StringHelper.class=org.apache.lucene.util.StringHelper, META-INF/versions/9/org/apache/lucene/util/automaton/Automaton$Builder.class=org.apache.lucene.util.automaton.Automaton$Builder, META-INF/versions/9/org/apache/lucene/util/bkd/BKDRadixSelector$1$1.class=org.apache.lucene.util.bkd.BKDRadixSelector$1$1, META-INF/versions/9/org/apache/lucene/analysis/tokenattributes/CharTermAttributeImpl.class=org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl, META-INF/versions/9/org/apache/lucene/util/bkd/BKDRadixSelector$2$1.class=org.apache.lucene.util.bkd.BKDRadixSelector$2$1, META-INF/versions/9/org/apache/lucene/util/BytesRef.class=org.apache.lucene.util.BytesRef, META-INF/versions/9/org/apache/lucene/document/BinaryPoint$2.class=org.apache.lucene.document.BinaryPoint$2, META-INF/versions/9/org/apache/lucene/document/RangeFieldQuery$QueryType$1.class=org.apache.lucene.document.RangeFieldQuery$QueryType$1, META-INF/versions/9/org/apache/lucene/index/CodecReader.class=org.apache.lucene.index.CodecReader, META-INF/versions/9/org/apache/lucene/util/automaton/Automaton.class=org.apache.lucene.util.automaton.Automaton, META-INF/versions/9/org/apache/lucene/util/bkd/BKDRadixSelector.class=org.apache.lucene.util.bkd.BKDRadixSelector, META-INF/versions/9/org/apache/lucene/util/bkd/MutablePointsReaderUtils$2.class=org.apache.lucene.util.bkd.MutablePointsReaderUtils$2, META-INF/versions/9/org/apache/lucene/document/LongRange.class=org.apache.lucene.document.LongRange, META-INF/versions/9/org/apache/lucene/index/MergeReaderWrapper.class=org.apache.lucene.index.MergeReaderWrapper, META-INF/versions/9/org/apache/lucene/util/CharsRef.class=org.apache.lucene.util.CharsRef, META-INF/versions/9/org/apache/lucene/codecs/compressing/LZ4.class=org.apache.lucene.codecs.compressing.LZ4, META-INF/versions/9/org/apache/lucene/document/LatLonPointDistanceQuery$1.class=org.apache.lucene.document.LatLonPointDistanceQuery$1, META-INF/versions/9/org/apache/lucene/document/DoubleRange.class=org.apache.lucene.document.DoubleRange, META-INF/versions/9/org/apache/lucene/document/FloatRange.class=org.apache.lucene.document.FloatRange, META-INF/versions/9/org/apache/lucene/document/RangeFieldQuery$QueryType$2.class=org.apache.lucene.document.RangeFieldQuery$QueryType$2, META-INF/versions/9/org/apache/lucene/util/bkd/BKDReader.class=org.apache.lucene.util.bkd.BKDReader, META-INF/versions/9/org/apache/lucene/util/CharsRef$UTF16SortedAsUTF8Comparator.class=org.apache.lucene.util.CharsRef$UTF16SortedAsUTF8Comparator, META-INF/versions/9/org/apache/lucene/util/bkd/MutablePointsReaderUtils$3$1.class=org.apache.lucene.util.bkd.MutablePointsReaderUtils$3$1, META-INF/versions/9/org/apache/lucene/util/bkd/HeapPointWriter.class=org.apache.lucene.util.bkd.HeapPointWriter, META-INF/versions/9/org/apache/lucene/document/LatLonPointInPolygonQuery$1$1.class=org.apache.lucene.document.LatLonPointInPolygonQuery$1$1, META-INF/versions/9/org/apache/lucene/search/BooleanScorer$TailPriorityQueue.class=org.apache.lucene.search.BooleanScorer$TailPriorityQueue, META-INF/versions/9/org/apache/lucene/util/bkd/MutablePointsReaderUtils$1$1.class=org.apache.lucene.util.bkd.MutablePointsReaderUtils$1$1, META-INF/versions/9/org/apache/lucene/document/IntRange.class=org.apache.lucene.document.IntRange, META-INF/versions/9/org/apache/lucene/document/LongDistanceFeatureQuery$DistanceScorer$2.class=org.apache.lucene.document.LongDistanceFeatureQuery$DistanceScorer$2, META-INF/versions/9/org/apache/lucene/index/CheckIndex$VerifyPointsVisitor.class=org.apache.lucene.index.CheckIndex$VerifyPointsVisitor, META-INF/versions/9/org/apache/lucene/search/PointInSetQuery$SinglePointVisitor.class=org.apache.lucene.search.PointInSetQuery$SinglePointVisitor, META-INF/versions/9/org/apache/lucene/search/TopFieldCollector.class=org.apache.lucene.search.TopFieldCollector, META-INF/versions/9/org/apache/lucene/document/LatLonPointDistanceFeatureQuery$DistanceScorer$2.class=org.apache.lucene.document.LatLonPointDistanceFeatureQuery$DistanceScorer$2, META-INF/versions/9/org/apache/lucene/util/bkd/BKDWriter$BKDMergeQueue.class=org.apache.lucene.util.bkd.BKDWriter$BKDMergeQueue, META-INF/versions/9/org/apache/lucene/util/bkd/BKDWriter.class=org.apache.lucene.util.bkd.BKDWriter, META-INF/versions/9/org/apache/lucene/util/BytesRefArray.class=org.apache.lucene.util.BytesRefArray, META-INF/versions/9/org/apache/lucene/util/IntsRef.class=org.apache.lucene.util.IntsRef, META-INF/versions/9/org/apache/lucene/index/BitsSlice.class=org.apache.lucene.index.BitsSlice, META-INF/versions/9/org/apache/lucene/document/RangeFieldQuery$QueryType$3.class=org.apache.lucene.document.RangeFieldQuery$QueryType$3, META-INF/versions/9/org/apache/lucene/index/PointValues.class=org.apache.lucene.index.PointValues, META-INF/versions/9/org/apache/lucene/util/bkd/BKDWriter$OneDimensionBKDWriter.class=org.apache.lucene.util.bkd.BKDWriter$OneDimensionBKDWriter}

Replies

Avatar

Avatar
Contributor
Employee
hamidk92094312
Employee

Likes

102 likes

Total Posts

240 posts

Correct Reply

38 solutions
Top badges earned
Contributor
Shape 1
Ignite 1
Give Back 50
Give Back 5
View profile

Avatar
Contributor
Employee
hamidk92094312
Employee

Likes

102 likes

Total Posts

240 posts

Correct Reply

38 solutions
Top badges earned
Contributor
Shape 1
Ignite 1
Give Back 50
Give Back 5
View profile
hamidk92094312
Employee

24-10-2019

Check this repo ... its old but can help you to get what you are looking for:

GitHub - viveksachdeva/elasticsearch-cq: Integration of ElasticSearch with CQ5

Avatar

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile
tadijam47062732
Level 2

24-10-2019

Tried that, but many things can not get resolved that way in my case.

Avatar

Avatar
Give Back 5
Employee
shunnar
Employee

Likes

12 likes

Total Posts

46 posts

Correct Reply

10 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile

Avatar
Give Back 5
Employee
shunnar
Employee

Likes

12 likes

Total Posts

46 posts

Correct Reply

10 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile
shunnar
Employee

24-10-2019

Can you run a clean of the Maven project? It could be old data from before making the changes have persisted

Avatar

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile
tadijam47062732
Level 2

25-10-2019

No, I run clean install

Avatar

Avatar
Validate 1
Level 4
cqsapientu69896
Level 4

Likes

22 likes

Total Posts

76 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Validate 1
Level 4
cqsapientu69896
Level 4

Likes

22 likes

Total Posts

76 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
cqsapientu69896
Level 4

26-02-2020

Hi @tadijam47062732 were you able to resolve it in the end? I am facing a similar issue while using elasticsearch in AEM. Can you please let me know?

Avatar

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile

Avatar
Validate 1
Level 2
tadijam47062732
Level 2

Likes

7 likes

Total Posts

28 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 5
View profile
tadijam47062732
Level 2

06-05-2020

@cqsapientu69896 you can see it here - I've manually created elasticsearch as separate OSGi bundles in Eclipse and reuse them in my project. You can check everything here: https://github.com/tadijam64/search-engines-comparison

Avatar

Avatar
Validate 1
Level 4
cqsapientu69896
Level 4

Likes

22 likes

Total Posts

76 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Validate 1
Level 4
cqsapientu69896
Level 4

Likes

22 likes

Total Posts

76 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
cqsapientu69896
Level 4

30-09-2020

Hi @tadijam47062732 thanks for replying we ended up using AWS lambda function but your reply might help someone else facing same issue