因外部依赖包内方法签名修改而导致线上NoSuchMethodError异常
NoSuchMethodError异常
问题描述
修复大数据组件包包中的漏洞,将hive-common 3.1.2版本升级到3.1.3,导致在连接hive表,查询schema时出现NosuchMethodError异常。
报错堆栈信息如下:
2023-02-24 14:48:00.931 [ERROR] com.ctyun.datacloud.service.exception.GlobalExceptionHandler.exception(GlobalExceptionHandler.java:33) - 系统出现未知异常:
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.apache.thrift.transport.TSocket.<init>(Ljava/lang/String;II)V
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1086) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:670) ~[tomcat-embed-core-9.0.68.jar!/:4.0.1]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779) ~[tomcat-embed-core-9.0.68.jar!/:4.0.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.jasig.cas.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:51) ~[cas-client-core-3.6.5-distributed.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:72) ~[cas-client-core-3.6.5-distributed.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:239) ~[cas-client-core-3.6.5-distributed.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:142) ~[spring-session-core-2.7.0.jar!/:2.7.0]
at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:82) ~[spring-session-core-2.7.0.jar!/:2.7.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) ~[spring-boot-actuator-2.7.5.jar!/:2.7.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.23.jar!/:5.3.23]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.23.jar!/:5.3.23]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.23.jar!/:5.3.23]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.jasig.cas.client.session.CustomerSingleSignOutFilter.doFilter(CustomerSingleSignOutFilter.java:93) ~[cas-client-support-springboot-3.6.5-distributed.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:769) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.68.jar!/:?]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.68.jar!/:?]
at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_212]
Caused by: java.lang.NoSuchMethodError: org.apache.thrift.transport.TSocket.<init>(Ljava/lang/String;II)V
at org.apache.hadoop.hive.common.auth.HiveAuthUtils.getSocketTransport(HiveAuthUtils.java:46) ~[hive-common-3.1.3.jar!/:3.1.3]
at org.apache.hive.jdbc.HiveConnection.createUnderlyingTransport(HiveConnection.java:561) ~[hive-jdbc-3.1.3.jar!/:3.1.3]
at org.apache.hive.jdbc.HiveConnection.createBinaryTransport(HiveConnection.java:581) ~[hive-jdbc-3.1.3.jar!/:3.1.3]
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:341) ~[hive-jdbc-3.1.3.jar!/:3.1.3]
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:228) ~[hive-jdbc-3.1.3.jar!/:3.1.3]
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107) ~[hive-jdbc-3.1.3.jar!/:3.1.3]
at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_212]
at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_212]
at com.ctyun.datacloud.service.thirdpart.hive.HiveService.execHiveDML(HiveService.java:108) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.thirdpart.hive.HiveService.listTables(HiveService.java:117) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.service.impl.ConnectorServiceImpl.listTables(ConnectorServiceImpl.java:699) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.service.impl.ConnectorServiceImpl$$FastClassBySpringCGLIB$$205d25e7.invoke(<generated>) ~[classes!/:1.0.0-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:73) ~[druid-1.1.22.jar!/:1.1.22]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.ctyun.datacloud.service.service.impl.ConnectorServiceImpl$$EnhancerBySpringCGLIB$$5e6a884a.listTables(<generated>) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.service.impl.TopicServiceImpl.listTable(TopicServiceImpl.java:1403) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.service.impl.TopicServiceImpl$$FastClassBySpringCGLIB$$f702345.invoke(<generated>) ~[classes!/:1.0.0-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:73) ~[druid-1.1.22.jar!/:1.1.22]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.ctyun.datacloud.service.service.impl.TopicServiceImpl$$EnhancerBySpringCGLIB$$1005cb24.listTable(<generated>) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.controller.TopicController.listTable(TopicController.java:89) ~[classes!/:1.0.0-SNAPSHOT]
at com.ctyun.datacloud.service.controller.TopicController$$FastClassBySpringCGLIB$$c80d662f.invoke(<generated>) ~[classes!/:1.0.0-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:123) ~[spring-context-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.ctyun.datacloud.service.aspect.ServiceAspect.around(ServiceAspect.java:43) ~[classes!/:1.0.0-SNAPSHOT]
at sun.reflect.GeneratedMethodAccessor193.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:73) ~[druid-1.1.22.jar!/:1.1.22]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar!/:5.3.23]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.23.jar!/:5.3.23]
at com.ctyun.datacloud.service.controller.TopicController$$EnhancerBySpringCGLIB$$d3396daa.listTable(<generated>) ~[classes!/:1.0.0-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.23.jar!/:5.3.23]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071) ~[spring-webmvc-5.3.23.jar!/:5.3.23]
... 52 more
问题思路
1. 常规思路
-
出现NoSuchMethodError的可能原因
NoSuchMethodError 是一个运行时异常,通常在以下两种情况下抛出:
- 调用一个不存在的方法。
- 方法签名发生了改变,导致编译时的调用与运行时的调用不一致。
在 Java 中,如果一个方法声明了抛出一个受检查的异常,而它的调用者没有处理这个异常,那么编译器会强制要求在调用处捕获或继续抛出这个异常。如果不这样做,代码将无法编译。
因此,如果你的代码没有捕获或继续抛出调用方法声明的受检查异常,那么你将会在编译时看到一个错误,而不是在运行时看到 NoSuchMethodError。
然而,如果你在运行时调用了一个不存在的方法,或者方法签名发生了改变,而你的代码没有被更新以反映这些变化,那么就可能会在运行时看到 NoSuchMethodError 异常。在这种情况下,你需要检查你的代码和所依赖的库,确保它们都是最新的,并且没有发生方法签名的改变。
-
什么情况会出现方法签名发生改变
在 Java 中,方法签名是指方法的名称、参数类型以及返回类型的组合。如果这些信息发生了改变,那么方法的签名也会随之改变。
下面是几种可能导致方法签名发生改变的情况:
- 修改方法的名称。
- 修改方法的参数类型或顺序。
- 修改方法的返回类型。
- 修改方法的访问修饰符。
- 修改方法的抛出异常类型。
这些改变可能是无意的,比如修改了方法名称但忘记修改所有引用该方法的地方。也可能是有意的,比如需要更新方法签名以反映新的需求或实现方式。
如果你的代码依赖于其他库或框架,那么你需要注意这些库或框架是否对方法签名进行了更改。如果是这样,你需要相应地更新你的代码以反映这些更改,否则可能会出现 NoSuchMethodError 异常。
2. 具体问题具体分析
-
堆栈主体报错为:
Caused by: java.lang.NoSuchMethodError: org.apache.thrift.transport.TSocket.<init>(Ljava/lang/String;II)V at org.apache.hadoop.hive.common.auth.HiveAuthUtils.getSocketTransport(HiveAuthUtils.java:46) ~[hive-common-3.1.3.jar!/:3.1.3]
可知 hive-common-3.1.3.jar中,执行
getSocketTransport
方法时,调用thrift.transport.TSocket
时出现NoSuchMethodError
-
查看源码
根据形参类型可知,找不到匹配的构造方法。
而thrift.transport.TSocket
的构造方法为TConfiguration config, String host, int port
,而不是TSocket(String host, int port, int loginTimeout)
,所以报错。
问题解决
到mvn仓库搜索发现,thrift-0.9.3.jar
为原配jar包,但有漏洞被替换成0.14.0版本,而0.14.0版本中thrift.transport.TSocket
没有构造方法为TSocket(String host, int port, int loginTimeout)
,所以报错。
找到thrift.transport.TSocket
的jar包,将其回退为thrift-0.9.3.jar
可以找到对应的构造方法。
考虑到0.9.3版本漏洞较多,所以升级到最近的可以使用的版本
发现0.17版本其实加入了此构造方法,但是抛出了异常,3.1.3的hive仍然无法准确识别此构造方法
问题总结
这问题非常有典型性,也有迷惑性
一般首先肯定想到的是jar包冲突引起的,但是此是方法签名改变导致的,而且不同版本暴露出不同的构造方法,有参数不匹配的,也有抛出异常不匹配的,比较难发现。
从这个问题中,不难看出开源社区的那些开发者们一直在与漏洞的斗争中,不断的更新版本,不断的修复漏洞,但是这些漏洞的修复,也会导致方法签名的改变,从而导致调用方的代码出现问题。最后做到了修复漏洞,但是又引入了新的问题。很难做到完美。
所以,大数据很多情况都会面对这些问题,所以在使用开源框架的时候,一定要注意版本的选择,不要随便升级,不要随便降级,要根据自己的业务场景,选择合适的版本。
tips
1. 英文
2. idea插件使用
-
maven helper
分析pom文件中的依赖关系
-
全局文件搜索快捷键
ctrl + shift + f(注意是否与搜狗输入法快捷键冲突)。