spring-cloud-alibaba-sentinel和feign配合使用,启动报Caused by: java.lang.AbstractMethodError: com.alibaba.cloud.sentinel.feign.SentinelContractHolder.parseAndValidateMetadata(Ljava/lang/Class;)Ljava/util/List

背景

我在学习spring-cloud-alibaba技术栈期间,在学习服务熔断与限流的时候,服务启动发生了以下异常

#这是控制台最上面的
sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 java.lang.Thread.run(Thread.java:748)

#下面的是这样
Caused by: java.lang.AbstractMethodError: com.alibaba.cloud.sentinel.feign.SentinelContractHolder.parseAndValidateMetadata(Ljava/lang/Class;)Ljava/util/List;
    at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:151) ~[feign-core-10.7.4.jar:na]
    at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:49) ~[feign-core-10.7.4.jar:na]
    at feign.Feign$Builder.target(Feign.java:252) ~[feign-core-10.7.4.jar:na]
    at org.springframework.cloud.openfeign.HystrixTargeter.target(HystrixTargeter.java:38) ~[spring-cloud-openfeign-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:253) ~[spring-cloud-openfeign-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.spring
framework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:282) ~[spring-cloud-openfeign-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:262) ~[spring-cloud-openfeign-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
    ... 33 common frames omitted

版本

 <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Hoxton.SR3</spring-cloud.version>
        <spring-cloud-alibaba.version>2.2.0.RELEASE</spring-cloud-alibaba.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

最后发现这个问题是由于版本冲突造成的,because:spring-cloud版本不同,openfeign的版本也不同

修改spring-cloud版本为

<spring-cloud.version>Hoxton.SR1</spring-cloud.version>
运行项目
2020-03-07 23:25:53.279  INFO 12452 --- [1)-192.168.81.1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-03-07 23:25:53.279  INFO 12452 --- [1)-192.168.81.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
INFO: log output type is: file
INFO: log charset is: utf-8
INFO: log base dir is: C:\Users\taoym\logs\cspINFO: log name use pid is: false
2020-03-07 23:25:53.295  INFO 12452 --- [1)-192.168.81.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 16 ms
测试服务熔断

总结

跟着官网的教程走,如果报错,那很有可能是版本的问题,多试几下就可以了!

原文地址:https://www.cnblogs.com/sxxs/p/12439258.html

时间: 2024-10-28 06:06:23

spring-cloud-alibaba-sentinel和feign配合使用,启动报Caused by: java.lang.AbstractMethodError: com.alibaba.cloud.sentinel.feign.SentinelContractHolder.parseAndValidateMetadata(Ljava/lang/Class;)Ljava/util/List的相关文章

Jenkins启动报 Caused by: java.io.IOException: 结构需要清理

我的Jenkins是安装在linux上的  今天启动突然启动不成了  报了如下错误 找到jenkins安装的目录 我的在/var/lib/jenkins下 目录下有一个workspace 把底下的文件删除就可以启动了  不过启动后 需要重新构建 要好长时间 建议安装插件workspace cleanup plugin   在项目构建后会自动清除工作空间中的文件 原文地址:https://www.cnblogs.com/fyg666/p/12122046.html

Weblogic 启动报错:java.lang.NoClassDefFoundError

Weblogic 启动报错:java.lang.NoClassDefFoundError  ####<2015-6-17 下午03时30分47秒 CST> <Error> <HTTP> <HDQSDOCMTAPP4> <zonyappserver> <[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS

【原】tomcat 7 启动报错:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig的解决

现象: tomcat 7 启动报错:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig 解决: 把tomcat目录下的lib/servlet-api.jar文件拷贝到$JAVA_HOME/jre/lib/ext目录下,再启动tomcat问题解决

tomcat启动报错:java.net.BindException: Permission denied &lt;null&gt;:80

1,启动报错显示 [org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization completed in 382 ms Jun 01, 2015 6:39:06 PM org.apache.coyote.http11.Http11Protocol start SEVERE: Error starting endpoint java.net.BindException:

SpringBoot项目启动报错:java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

.   ____          _            __ _ _ /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/  ___)| |_)| | | | | || (_| |  ) ) ) )  '  |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Sprin

[tomcat启动报错]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped

环境:一个tomcat ,一个工程配置了多数据源,在启动的时候报如下错误: SEVERE: The web application [/qdp-resource-job] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDB

maven项目在eclipse启动报错:java.lang.ClassNotFoundException

问题: 用eclipse创建maven项目的时候,pom.xml中相关的依赖jar已经导入进去,还会报java.lang.ClassNotFoundException的错误,提示找不到相关的jar包,但是在maven Dependencies中又可以找到相关的jar包. 问题原因: 我们进入到tomcat的部署路径下:E:\workplace4.6\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc.r

myeclipse启动报错 no java virtual machine。。。

如果环境变量里已经配置了JAVA_HOME,但是在启动的时候还会提示下面的信息: A Java Runtime Environment (JRE) or Java Development Kit (JDK)must be available in order to run Eclipse. No Java virtual machinewas found after searching the following locations:jvm.dll" 原因可能是因为myeclipse是从别的电脑

eclipse启动报错A Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse.

Eclipse启动时报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No java virtual machine was found after searching the following locations:… 此问题起于我在Ubuntu1004上装了两个版本的eclipse:Galieo+helios:卸载前者后出现启