Transitive Dependency: Using Elasticsearch Rest High Client problem in AEM

前端 未结 1 681
谎友^
谎友^ 2021-02-06 13:52

I am trying to use Java High Level Rest Client in Adobe Experience Manager to finish project of comparison between Lucene, Solr and Elasticsearch search

1条回答
  •  悲&欢浪女
    2021-02-06 14:21

    So my guess was right, transitive dependencies were not included altho true exists.

    The following is necessary when running elasticsearch as a search engine on AEM the problem:

    • I have added all transitive dependencies in pom.xml (versions are defined in parent/pom.xml):

        
            
                org.elasticsearch.client
                elasticsearch-rest-high-level-client
            
            
                org.elasticsearch.client
                elasticsearch-rest-client
            
            
                org.elasticsearch
                elasticsearch
            
            
                org.elasticsearch
                elasticsearch-x-content
            
            
                org.elasticsearch.plugin
                rank-eval-client
            
            
                org.apache.commons
                commons-imaging
                test
            
            
                org.elasticsearch.plugin
                lang-mustache-client
            
            
                org.apache.httpcomponents
                httpasyncclient
            
      

    It is important to add all third-party dependencies as <Embed-Dependency> inside maven-bundle-plugin like this:

        
            org.apache.felix
            maven-bundle-plugin
            true
            
                
                    org.apache.servicemix.bundles.solr-solrj, noggit,
                        elasticsearch-rest-high-level-client,
                        elasticsearch,
                        elasticsearch-rest-client,
                        elasticsearch-x-content,
                        elasticsearch-core,
                        rank-eval-client,
                        lang-mustache-client,
                        httpasyncclient;
                    
                    true
                    OSGI-INF/lib
                    we.retail.core.model*
                    
                        *;resolution:=optional
                    
                    
                        we.retail.core*
                    
                    
                        we.retail.core.model
                    
                    <_fixupmessages>"Classes found in the wrong directory";is:=warning
                
            
        
    

    Important to notice:

    • All third-party dependencies (the ones outside of OSGi) must be included in the "Embed-Dependency"
    • "Embed-Transitive" must be set to true to include transitive dependencies
    • "Import-Package" must include "*;resolution:=optional" to exclude all dependencies that could not be resolved so that the program can run normally
    • For some reason, there was an error in compile time when "elasticsearch" dependency was added which is not important for this task, so I've decided to ignore it this way:
    <_fixupmessages>"Classes found in the wrong directory";is:=warning
    

    Though challenging, I finally resolved it. There are many similar or the same problems on Google, so I hope this will help someone. Thanks to everyone that tried to help.

    0 讨论(0)
提交回复
热议问题