Elasticsearch 7.8与Magnolia 6.2.x

huangapple 未分类评论45阅读模式
英文:

Elasticsearch 7.8 with Magnolia 6.2.x

问题

我想使用最新的 Elasticsearch 版本(7.8.0)与最新的 Mgnl(CE)版本(当前为6.2.2)。在一些旧项目中,它们经常使用 Elasticsearch 版本<3.6,并且对于所有的 API 调用,如搜索/索引查询,它们使用 Elastic 的旧传输客户端。该客户端将在 Elastic 的 v8 中被移除,并将由 Elastic 的 Rest-High-Level-Client API 替代。

为了进行测试,我通过 mvn 构建原型生成方式使用空白的 mgnl 6.2.2,并在 mgnl 中设置了一个简单的模块,其中包含一个虚拟页面和虚拟组件。为了测试结果,我修改了虚拟组件,调用以下代码片段作为组件模型。

我的模型:

package com.test.model;

import javax.jcr.Node;

import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.search.builder.SearchSourceBuilder;

import info.magnolia.rendering.model.RenderingModel;
import info.magnolia.rendering.model.RenderingModelImpl;
import info.magnolia.rendering.template.TemplateDefinition;

public class TestModel extends RenderingModelImpl<TemplateDefinition> {

    public TestModel(Node content, TemplateDefinition definition, RenderingModel<?> parent) {
        super(content, definition, parent);
    }

    public void init( ) {
        SearchRequest test = new SearchRequest();
        SearchSourceBuilder testSource = new SearchSourceBuilder();
        test.source(testSource);
        System.out.println("test done");
    }
}

以下是我的 pom 文件:

<!-- Test-Module pom.xml -->
<!-- ... -->
<!-- parent-pom pom.xml -->
<!-- ... -->

如果我尝试设置一个类似 TestModel 中所写的使用 SearchRequest 和 SearchSourceBuilder 的简单搜索请求,我会得到以下异常:

Caused by: java.lang.NoSuchFieldError: LATEST
    at org.elasticsearch.Version.<clinit>(Version.java:59)
    at org.elasticsearch.common.logging.DeprecationLogger.<clinit>(DeprecationLogger.java:143)
    at org.elasticsearch.search.builder.SearchSourceBuilder.<clinit>(SearchSourceBuilder.java:83)
    at com.test.model.TestModel.init(TestModel.java:20)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1505)
    at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:72)

在阅读了一些论坛后,我注意到这是由于不同版本的 lucene-core 导致的问题。您可以通过以下命令查看所包含的 lucene-core 版本:

mvn dependency:tree -Dverbose -Dincludes=org.apache.lucene

通过上述输出,您可以看到依赖 mgnl-core 包含了 jackrabbit-core 2.20.0 中的 lucene-core v3.6。如果您尝试排除 lucene v3.6 并仅包含来自 elasticsearch v7.8 的版本,您将遇到另一个异常。

我希望这些信息对您有所帮助。如果您有进一步的问题或需要更多帮助,请随时提问。

英文:

i want to use the latest elasticsearch version (7.8.0) with the latest Mgnl (CE) version (currently 6.2.2). In some older project they often use elastic with version <3.6 and for all api calls like search / indexing queries they use the old transport client of Elastic. That client will be removed with v8 of elastic and will be replaced by the Rest-High-Level-Client Api of elastic.

For my test i used a blank mgnl 6.2.2 via mvn archetype generation and setup a simple module from mgnl with a dummy page and dummy component. To test the result, i modified that dummy to call the following code snippet as component model.

My model :

package com.test.model;

import javax.jcr.Node;

import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.search.builder.SearchSourceBuilder;

import info.magnolia.rendering.model.RenderingModel;
import info.magnolia.rendering.model.RenderingModelImpl;
import info.magnolia.rendering.template.TemplateDefinition;

public class TestModel extends RenderingModelImpl&lt;TemplateDefinition&gt;{

	public TestModel(Node content, TemplateDefinition definition, RenderingModel&lt;?&gt; parent) {
		super(content, definition, parent);
	}

	public void init( ) {
		SearchRequest test = new SearchRequest();
		SearchSourceBuilder testSource = new SearchSourceBuilder();
		test.source(testSource);
		System.out.println(&quot;test done&quot;);
	}
}

here are my pom's :

Test-Module :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;parent&gt;
		&lt;groupId&gt;com.test&lt;/groupId&gt;
		&lt;artifactId&gt;mgnl&lt;/artifactId&gt;
		&lt;version&gt;1&lt;/version&gt;
		&lt;relativePath&gt;../pom.xml&lt;/relativePath&gt;
	&lt;/parent&gt;
	&lt;artifactId&gt;mgnl-web&lt;/artifactId&gt;
	&lt;packaging&gt;jar&lt;/packaging&gt;
	&lt;name&gt;mgnl-web Magnolia Module&lt;/name&gt;
	&lt;!-- &lt;description&gt;Please uncomment and fill in ...&lt;/description&gt; --&gt;
	&lt;properties&gt;
		&lt;magnoliaBundleVersion&gt;6.2.2&lt;/magnoliaBundleVersion&gt;
		&lt;javaVersion&gt;1.8&lt;/javaVersion&gt;
	&lt;/properties&gt;

	&lt;dependencyManagement&gt;
		&lt;dependencies&gt;
			&lt;dependency&gt;
				&lt;groupId&gt;info.magnolia.bundle&lt;/groupId&gt;
				&lt;artifactId&gt;magnolia-bundle-parent&lt;/artifactId&gt;
				&lt;version&gt;${magnoliaBundleVersion}&lt;/version&gt;
				&lt;type&gt;pom&lt;/type&gt;
				&lt;scope&gt;import&lt;/scope&gt;
			&lt;/dependency&gt;
		&lt;/dependencies&gt;
	&lt;/dependencyManagement&gt;

	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;info.magnolia&lt;/groupId&gt;
			&lt;artifactId&gt;magnolia-rendering&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.elasticsearch&lt;/groupId&gt;
			&lt;artifactId&gt;elasticsearch&lt;/artifactId&gt;
			&lt;version&gt;7.8.0&lt;/version&gt;
			&lt;exclusions&gt;
				&lt;exclusion&gt;
					&lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
					&lt;artifactId&gt;*&lt;/artifactId&gt;
				&lt;/exclusion&gt;
			&lt;/exclusions&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.elasticsearch.client&lt;/groupId&gt;
			&lt;artifactId&gt;elasticsearch-rest-high-level-client&lt;/artifactId&gt;
			&lt;version&gt;7.8.0&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;info.magnolia&lt;/groupId&gt;
			&lt;artifactId&gt;magnolia-core&lt;/artifactId&gt;
		&lt;/dependency&gt;

		&lt;!-- TEST --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;junit&lt;/groupId&gt;
			&lt;artifactId&gt;junit&lt;/artifactId&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;

	&lt;build&gt;
    	&lt;plugins&gt;
    		&lt;plugin&gt;
    			&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
    			&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
    			&lt;version&gt;3.7.0&lt;/version&gt;
    			&lt;configuration&gt;
					&lt;source&gt;${javaVersion}&lt;/source&gt;
					&lt;target&gt;${javaVersion}&lt;/target&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;

		&lt;!-- default resources configuration which will filter the module descriptor --&gt;
		&lt;resources&gt;
			&lt;resource&gt;
				&lt;directory&gt;src/main/resources&lt;/directory&gt;
				&lt;includes&gt;
					&lt;include&gt;**/*&lt;/include&gt;
				&lt;/includes&gt;
			&lt;/resource&gt;
			&lt;resource&gt;
				&lt;filtering&gt;true&lt;/filtering&gt;
				&lt;directory&gt;src/main/resources&lt;/directory&gt;
				&lt;includes&gt;
			    	&lt;include&gt;META-INF/magnolia/*&lt;/include&gt;
		    	&lt;/includes&gt;
	    	&lt;/resource&gt;
    	&lt;/resources&gt;
	&lt;/build&gt;

	&lt;repositories&gt;
    	&lt;repository&gt;
    		&lt;id&gt;magnolia.public&lt;/id&gt;
    		&lt;url&gt;https://nexus.magnolia-cms.com/content/groups/public&lt;/url&gt;
    		&lt;snapshots&gt;
    			&lt;enabled&gt;true&lt;/enabled&gt;
    		&lt;/snapshots&gt;
    	&lt;/repository&gt;
		&lt;!-- IF YOU NEED MODULES FROM THE ENTERPRISE VERSION, UNCOMMENT THE FOLLOWING 
		REPOSITORY --&gt;
		&lt;!-- &lt;repository&gt; &lt;id&gt;magnolia.enterprise.releases&lt;/id&gt; &lt;url&gt;https://nexus.magnolia-cms.com/content/repositories/magnolia.enterprise.releases&lt;/url&gt; 
			&lt;snapshots&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;/snapshots&gt; &lt;/repository&gt; --&gt;
		&lt;repository&gt;
			&lt;id&gt;vaadin-addons&lt;/id&gt;
		    &lt;url&gt;https://maven.vaadin.com/vaadin-addons&lt;/url&gt;
	    &lt;/repository&gt;
    &lt;/repositories&gt;

&lt;/project&gt;

parent-pom (Untouched generation via mgnl mvn archetype) :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;groupId&gt;com.test&lt;/groupId&gt;
	&lt;artifactId&gt;mgnl&lt;/artifactId&gt;
	&lt;name&gt;mgnl (parent pom)&lt;/name&gt;
	&lt;version&gt;1&lt;/version&gt;
	&lt;packaging&gt;pom&lt;/packaging&gt;

	&lt;properties&gt;
	    &lt;magnoliaBundleVersion&gt;6.2.2&lt;/magnoliaBundleVersion&gt;
    	&lt;javaVersion&gt;1.8&lt;/javaVersion&gt;
	&lt;/properties&gt;

	&lt;!-- Fill the following in, so you can use the release plugin --&gt;
	&lt;scm&gt;
	    &lt;connection /&gt;
    	&lt;developerConnection /&gt;
		&lt;url /&gt;
	&lt;/scm&gt;

    &lt;dependencyManagement&gt;
    	&lt;dependencies&gt;
		    &lt;!-- Option A --&gt;
	    	&lt;!-- Importing dependencyManagement of CE bundle. --&gt;
    		&lt;dependency&gt;
				&lt;groupId&gt;info.magnolia.bundle&lt;/groupId&gt;
			    &lt;artifactId&gt;magnolia-bundle-parent&lt;/artifactId&gt;
		    	&lt;version&gt;${magnoliaBundleVersion}&lt;/version&gt;
	    		&lt;type&gt;pom&lt;/type&gt;
    			&lt;scope&gt;import&lt;/scope&gt;
				&lt;exclusions&gt;
				    &lt;exclusion&gt;
			    		&lt;artifactId&gt;*&lt;/artifactId&gt;
		    			&lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
	    			&lt;/exclusion&gt;
    			&lt;/exclusions&gt;
			&lt;/dependency&gt;

	    	&lt;!-- Option B --&gt;
    		&lt;!-- If you want to use the DX CORE. --&gt;
			&lt;!-- &lt;dependency&gt; &lt;groupId&gt;info.magnolia.dx&lt;/groupId&gt; &lt;artifactId&gt;magnolia-dx-core-parent&lt;/artifactId&gt; 
		    	&lt;version&gt;${magnoliaBundleVersion}&lt;/version&gt; &lt;type&gt;pom&lt;/type&gt; &lt;scope&gt;import&lt;/scope&gt; 
	    		&lt;/dependency&gt; --&gt;
    	&lt;/dependencies&gt;
	&lt;/dependencyManagement&gt;


    &lt;build&gt;
    	&lt;plugins&gt;
			&lt;plugin&gt;
		    	&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
	    		&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
    			&lt;version&gt;3.7.0&lt;/version&gt;
				&lt;configuration&gt;
			    	&lt;source&gt;${javaVersion}&lt;/source&gt;
		    		&lt;target&gt;${javaVersion}&lt;/target&gt;
	    		&lt;/configuration&gt;
    		&lt;/plugin&gt;
		&lt;/plugins&gt;

	    &lt;!-- default resources configuration which will filter your module descriptors --&gt;
	    &lt;resources&gt;
	    	&lt;resource&gt;
    			&lt;directory&gt;src/main/resources&lt;/directory&gt;
				&lt;includes&gt;
			    	&lt;include&gt;**/*&lt;/include&gt;
		    	&lt;/includes&gt;
	    	&lt;/resource&gt;
		    &lt;resource&gt;
	    		&lt;filtering&gt;true&lt;/filtering&gt;
    			&lt;directory&gt;src/main/resources&lt;/directory&gt;
				&lt;includes&gt;
				    &lt;include&gt;META-INF/magnolia/*&lt;/include&gt;
			    &lt;/includes&gt;
		    &lt;/resource&gt;
	    &lt;/resources&gt;
    &lt;/build&gt;

    &lt;repositories&gt;
	    &lt;repository&gt;
    		&lt;id&gt;magnolia.public&lt;/id&gt;
			&lt;url&gt;https://nexus.magnolia-cms.com/content/groups/public&lt;/url&gt;
	    	&lt;snapshots&gt;
    			&lt;enabled&gt;true&lt;/enabled&gt;
			&lt;/snapshots&gt;
	    &lt;/repository&gt;
	    &lt;!-- IF YOU NEED MODULES FROM THE ENTERPRISE VERSION, UNCOMMENT THE FOLLOWING 
	    	REPOSITORY --&gt;
	    &lt;!-- &lt;repository&gt; &lt;id&gt;magnolia.enterprise.releases&lt;/id&gt; &lt;url&gt;https://nexus.magnolia-cms.com/content/repositories/magnolia.enterprise.releases&lt;/url&gt; 
	    	&lt;snapshots&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;/snapshots&gt; &lt;/repository&gt; --&gt;
	    &lt;repository&gt;
    		&lt;id&gt;vaadin-addons&lt;/id&gt;
			&lt;url&gt;https://maven.vaadin.com/vaadin-addons&lt;/url&gt;
		&lt;/repository&gt;
	&lt;/repositories&gt;

	&lt;modules&gt;
		&lt;module&gt;mgnl-webapp&lt;/module&gt;
		&lt;module&gt;mgnl-web&lt;/module&gt;
	&lt;/modules&gt;
&lt;/project&gt;

If i try to setup a simple SearchRequest with SearchSourceBuilder like that one written in the TestModel i got the following exception :

Caused by: java.lang.NoSuchFieldError: LATEST
at org.elasticsearch.Version.&lt;clinit&gt;(Version.java:59)
at org.elasticsearch.common.logging.DeprecationLogger.&lt;clinit&gt;(DeprecationLogger.java:143)
at org.elasticsearch.search.builder.SearchSourceBuilder.&lt;clinit&gt;(SearchSourceBuilder.java:83)
at com.test.model.TestModel.init(TestModel.java:20)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1505)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:72)

after reading some forums i noticed that it happens if there are different versions of lucene-core so i figured out which versions are presented with :

mvn dependency:tree -Dverbose -Dincludes=org.apache.lucene

and got the following result :

[INFO] -------------------------&lt; com.test:mgnl-web &gt;--------------------------
[INFO] Building mgnl-web Magnolia Module 1                                [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mgnl-web ---
[INFO] com.test:mgnl-web:jar:1
[INFO] +- org.elasticsearch:elasticsearch:jar:7.8.0:compile
[INFO] |  +- org.apache.lucene:lucene-core:jar:3.6.0:compile
[INFO] |  +- org.apache.lucene:lucene-analyzers-common:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-backward-codecs:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-grouping:jar:8.5.1:compile
[INFO] |  |  +- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  |  \- (org.apache.lucene:lucene-queries:jar:8.5.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-highlighter:jar:8.5.1:compile
[INFO] |  |  +- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  |  +- (org.apache.lucene:lucene-memory:jar:8.5.1:compile - omitted for duplicate)
[INFO] |  |  \- (org.apache.lucene:lucene-queries:jar:8.5.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-join:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-memory:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-misc:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-queries:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-queryparser:jar:8.5.1:compile
[INFO] |  |  +- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  |  +- (org.apache.lucene:lucene-queries:jar:8.5.1:compile - omitted for duplicate)
[INFO] |  |  \- (org.apache.lucene:lucene-sandbox:jar:8.5.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-sandbox:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-spatial-extras:jar:8.5.1:compile
[INFO] |  |  +- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  |  \- (org.apache.lucene:lucene-spatial3d:jar:8.5.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.lucene:lucene-spatial3d:jar:8.5.1:compile
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] |  \- org.apache.lucene:lucene-suggest:jar:8.5.1:compile
[INFO] |     +- (org.apache.lucene:lucene-analyzers-common:jar:8.5.1:compile - omitted for duplicate)
[INFO] |     \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO] \- info.magnolia:magnolia-core:jar:6.2.2:compile
[INFO]    +- org.apache.jackrabbit:jackrabbit-core:jar:2.20.0:compile
[INFO]    |  \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)
[INFO]    \- (org.apache.lucene:lucene-core:jar:3.6.0:compile - version managed from 8.5.1; omitted for duplicate)

as shown above the dependency mgnl-core contains the lucene-core v3.6 from jackrabbit-core 2.20.0

if i try to to exclude lucene v3.6 and only include that one from elasticsearch v7.8 with the following pom changes at my test module above :

&lt;dependencies&gt;
    &lt;dependency&gt;
    	&lt;groupId&gt;info.magnolia&lt;/groupId&gt;
    	&lt;artifactId&gt;magnolia-rendering&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
    	&lt;groupId&gt;org.elasticsearch&lt;/groupId&gt;
    	&lt;artifactId&gt;elasticsearch&lt;/artifactId&gt;
    	&lt;version&gt;7.8.0&lt;/version&gt;
   &lt;/dependency&gt;
    &lt;dependency&gt;
    	&lt;groupId&gt;org.elasticsearch.client&lt;/groupId&gt;
    	&lt;artifactId&gt;elasticsearch-rest-high-level-client&lt;/artifactId&gt;
    	&lt;version&gt;7.8.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
    	&lt;groupId&gt;info.magnolia&lt;/groupId&gt;
    	&lt;artifactId&gt;magnolia-core&lt;/artifactId&gt;
    	&lt;exclusions&gt;
    		&lt;exclusion&gt;
    			&lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
    			&lt;artifactId&gt;*&lt;/artifactId&gt;
    		&lt;/exclusion&gt;
    	&lt;/exclusions&gt;
    &lt;/dependency&gt;
    	&lt;!-- TEST --&gt;
    &lt;dependency&gt;
    	&lt;groupId&gt;junit&lt;/groupId&gt;
	    &lt;artifactId&gt;junit&lt;/artifactId&gt;
    	&lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

and the following exception will happen :

java.lang.IllegalAccessError: class org.apache.jackrabbit.core.query.lucene.JackrabbitAnalyzer tried to access protected method org.apache.lucene.analysis.StopwordAnalyzerBase.&lt;init&gt;(Lorg/apache/lucene/util/Version;Ljava/util/Set;)V (org.apache.jackrabbit.core.query.lucene.JackrabbitAnalyzer and org.apache.lucene.analysis.StopwordAnalyzerBase are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @479f2dc2)
    at org.apache.jackrabbit.core.query.lucene.JackrabbitAnalyzer.&lt;clinit&gt;(JackrabbitAnalyzer.java:46) ~[jackrabbit-core-2.20.0.jar:2.20.0]
    at org.apache.jackrabbit.core.query.lucene.SearchIndex.&lt;init&gt;(SearchIndex.java:232) ~[jackrabbit-core-2.20.0.jar:2.20.0]
    at info.magnolia.jackrabbit.lucene.SearchIndex.&lt;init&gt;(SearchIndex.java:67) ~[magnolia-core-6.2.2.jar:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.__newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45009) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45012) ~[?:?]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
    at java.lang.Class.newInstance(Class.java:584) ~[?:?]

after reading some threads i noticed that this happen due to the standart configuration of mgnl repo conf with jackrabbit @h2 db : jackrabbit-bundle-h2-search.xml that setup the searchindex of the jcr repositories that used jackrabbit's searchindex @org.apache.jackrabbit.core.query.lucene.SearchIndex

i spend a lot of time to fix that without disabling the Searchindex. Does anybody has an idea how to fix that to run magnolia 6.2.x with the new Rest-High-Level-Client of Elastic ?

greetings so long, hope anybody can help Elasticsearch 7.8与Magnolia 6.2.x

p.s: for the archetype generation @example i used the following command to setup :

mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeCatalog=https://nexus.magnolia-cms.com/content/groups/public/

huangapple
  • 本文由 发表于 2020年7月24日 12:29:36
  • 转载请务必保留本文链接:https://java.coder-hub.com/63066837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定