首页 > 编程语言 >ES7.17.20连接时报错:java.lang.NoSuchMethodError: org.elasticsearch.client.RequestOptions$Builder.removeHe

ES7.17.20连接时报错:java.lang.NoSuchMethodError: org.elasticsearch.client.RequestOptions$Builder.removeHe

时间:2024-04-14 11:44:57浏览次数:53  
标签:lang core java 46 Builder jar org 9.0 RequestOptions

1.报错详情:

java.lang.NoSuchMethodError: org.elasticsearch.client.RequestOptions$Builder.removeHeader(Ljava/lang/String;)Lorg/elasticsearch/client/RequestOptions$Builder;
	at co.elastic.clients.transport.rest_client.RestClientOptions.addBuiltinHeaders(RestClientOptions.java:195) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientOptions.<init>(RestClientOptions.java:67) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientOptions.initialOptions(RestClientOptions.java:191) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientOptions.of(RestClientOptions.java:52) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientHttpClient.createOptions(RestClientHttpClient.java:84) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientHttpClient.createOptions(RestClientHttpClient.java:48) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.ElasticsearchTransportBase.<init>(ElasticsearchTransportBase.java:108) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientTransport.<init>(RestClientTransport.java:36) ~[elasticsearch-java-7.17.20.jar:na]
	at co.elastic.clients.transport.rest_client.RestClientTransport.<init>(RestClientTransport.java:32) ~[elasticsearch-java-7.17.20.jar:na]
	at com.xurong.gulimallsearch.controller.TestSearchController.test(TestSearchController.java:34) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_311]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_311]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_311]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_311]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.46.jar:4.0.FR]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.46.jar:4.0.FR]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_311]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_311]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.46.jar:9.0.46]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_311]

2.报错原因

该原因官网有解决方案:https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.17/no-such-method-request-options.html
分析:

RequestOptions$Builder.removeHeader:elasticsearch-rest-clien7.6.2中的RequestOptions.Builder类中没有removeHeader方法

解决:

   <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>7.17.20</version>
        </dependency>
<!--        引入jackson-databind会导致报错:缺少jackson相关依赖-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.17.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.17.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.17.0</version>
        </dependency>
        <dependency>
            <groupId>jakarta.json</groupId>
            <artifactId>jakarta.json-api</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>7.17.20</version>
        </dependency>

参考:
参考1:https://www.cnblogs.com/ergwang/p/17307099.html
参考2:https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.17/no-such-method-request-options.html

标签:lang,core,java,46,Builder,jar,org,9.0,RequestOptions
From: https://www.cnblogs.com/rong-xu-drum/p/18133925

相关文章

  • 使用java client连接ES7.17.20时报错:Caused by: java.lang.NoClassDefFoundError: Cou
    1.报错详情Causedby:java.lang.NoClassDefFoundError:Couldnotinitializeclasscom.fasterxml.jackson.databind.cfg.DatatypeFeatures$DefaultHolder atcom.fasterxml.jackson.databind.cfg.DatatypeFeatures.defaultFeatures(DatatypeFeatures.java:33)~[jackson-data......
  • bug记录:java.lang.UnsupportedOperationException: null
    java.lang.UnsupportedOperationException:null这个错一般是因为不支持的操作导致,即对象不支持某方法,显示抛出此异常。举个例子:Arrays.asList这个方法返回Arrays内部类ArrayList而不是java.util.ArrayList,而Arrays的内部类ArrayList是继承了AbstractList,AbstractList中的add、r......
  • 脑洞golang embed 的使用场景
    golang的embed的功能真是一个很神奇的功能,它能把静态资源,直接在编译的时候,打包到最终的二进制程序中。为什么会设计这么一个功能呢?我想和golang的崇尚简单的原则有关系吧。它希望的是一个二进制文件能走天下,那么如果你作为一个web服务器,还需要依赖一大堆的静态文件,终究不......
  • golang JSON序列化和反序列化
    目录JSON序列化(Marshaling)JSON反序列化(Unmarshaling)错误处理和注意事项在Go语言(通常被称为Golang)中,JSON(JavaScriptObjectNotation)是一种常用的数据交换格式。Go标准库提供了encoding/json包,使得JSON的序列化(将Go数据结构转换为JSON格式的字符串)和反序列化(将JSON格式的字符串......
  • Kaggle自然语言处理入门 推特灾难文本分类 Natural Language Processing with Disaste
    和新闻按照标题分类差不多,用的朴素贝叶斯#导入必要的包importrandomimportsysfromsklearnimportmodel_selectionfromsklearn.naive_bayesimportMultinomialNBimportjoblibimportre,stringimportpandasaspdimportnumpyasnpdeftext_to_words(file_path)......
  • Golang 中 在gmp下,mutex 是如何并发的
    在Go语言的并发模型中,GMP(Goroutine、Machine、Processor)模型是核心概念,其中Mutex(互斥锁)扮演着关键的角色,用于同步并发访问共享资源,防止数据竞争和不一致性问题。以下是Mutex在GMP模型下实现并发的详细解释:Goroutines(协程)轻量级的线程:Goroutines是Go语言中的轻量级线程,它......
  • golang实现R6900路由器外网IP更新通知程序
    程序一分钟执行一次,检测路由器外网IP地址变更则自动发送邮件,使用网易126smtp协议发送邮件,邮箱地址及授权码请自行替换,getIp函数中的grep根据自己的网卡信息调试替换R6900路由器的交叉编译语句:CGO_ENABLED=0GOOS=linuxGOARCH=armGOARM=5gobuildxxxx.go1234567......
  • org.apache.commons.lang3.ArrayUtils 学习笔记
    1234567891011121314151617181920212223242526272829303132333435package com.nihaorz.model; /** *@作者王睿 *@时间2016-5-17上午10:05:17 * */public class Person{    private Stringid;    pr......
  • Bridging Causal Discovery and Large Language Models
    本文是LLM系列文章,针对《BridgingCausalDiscoveryandLargeLanguageModels:AComprehensiveSurveyofIntegrativeApproachesandFutureDirections》的翻译。连接因果发现和大型语言模型:集成方法和未来方向的综合综述摘要1引言2背景3问题定义4当前的......
  • A Comprehensive Evaluation of Sequential Memory Editing in Large Language Models
    本文是LLM系列文章,针对《NavigatingtheDualFacets:AComprehensiveEvaluationofSequentialMemoryEditinginLargeLanguageModels》的翻译。双向导航:大型语言模型中顺序记忆编辑的综合评价摘要1引言2相关工作3符号和背景4实验设置5ME对LLM的评估......