0

当我们为索引调用 getMapping 或在下面创建索引函数时使用 java-high-level-rest 客户端,每次都会生成错误。几乎所有与索引相关的调用都会产生此异常。

bootstrap method initialization exception
at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:194)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:315)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:259)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:249)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1883)
at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$9(RestHighLevelClient.java:1564)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1628)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1596)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1563)
at org.elasticsearch.client.IndicesClient.getMapping(IndicesClient.java:282)

Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type interface org.apache.http.Header; not a subtype of implementation type interface org.apache.http.NameValuePair
at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:254)
at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:327)
at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:127)

我正在使用以下环境

弹性搜索 - 7.8.0。openJDK - 11 和 14、JDK 1.8 elasticsearch-rest-high-level-client-7.8.0.jar 及其依赖项包含在 pom.xml 操作系统中:尝试了 Windows 10 和 Linux Mint。

4

3 回答 3

2

我得到了同样的错误,我发现httpcore版本不正确。我这样的依赖

<dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>7.16.2</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>7.16.2</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.16.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.12</version>
        </dependency>
于 2021-12-23T09:20:23.650 回答
0

更改您的 pom.xml 配置

可能是您的 elasticsearch-rest-high-level-client 版本太高。

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

做完之后就正常了

于 2020-08-02T09:32:33.237 回答
0

由于与 httpcore 依赖项的冲突,我遇到了这个问题,特别是 httpcore 和 httpcore-nio 不兼容。深入研究您的 elasticsearch-rest-client 版本的 pom 并使用与那里相同的版本,或者将它们从您的其他依赖项中排除。

于 2022-01-14T16:49:22.080 回答