请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

AHAS整合问题

大目老师好,我在整合ahas的时候遇到了问题,引入了ahas依赖后项目启动报错。

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.alibaba.csp</groupId>
                <artifactId>sentinel-transport-simple-http</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.alibaba.csp</groupId>
        <artifactId>spring-boot-starter-ahas-sentinel-client</artifactId>
        <version>1.10.1</version>
    </dependency>

报错日志如下:

2021-12-06 15:40:48.203 INFO 12216 — [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-12-06 15:40:48.206 WARN 12216 — [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [logback-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizerConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)java.util.concurrent.ScheduledThreadPoolExecutorConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) java.util.concurrent.ScheduledThreadPoolExecutorConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)java.util.concurrent.ThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) java.util.concurrent.ThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
2021-12-06 15:40:48.206 WARN 12216 — [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
2021-12-06 15:40:48.206 WARN 12216 — [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.client.listener] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizerConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)com.alibaba.nacos.client.naming.core.EventDispatcherConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467) com.alibaba.nacos.client.naming.core.EventDispatcherConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)com.alibaba.nacos.client.naming.core.EventDispatcherNotifier.run(EventDispatcher.java:114)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:624)java.lang.Thread.run(Thread.java:748)2021−12−0615:40:48.207WARN12216−−−[main]o.a.c.loader.WebappClassLoaderBase:Thewebapplication[ROOT]appearstohavestartedathreadnamed[com.alibaba.nacos.naming.beat.sender]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.Stacktraceofthread:sun.misc.Unsafe.park(NativeMethod)java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)java.util.concurrent.locks.AbstractQueuedSynchronizerWorker.run(ThreadPoolExecutor.java:624) java.lang.Thread.run(Thread.java:748) 2021-12-06 15:40:48.207 WARN 12216 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.beat.sender] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) java.util.concurrent.locks.AbstractQueuedSynchronizerWorker.run(ThreadPoolExecutor.java:624)java.lang.Thread.run(Thread.java:748)2021120615:40:48.207WARN12216[main]o.a.c.loader.WebappClassLoaderBase:Thewebapplication[ROOT]appearstohavestartedathreadnamed[com.alibaba.nacos.naming.beat.sender]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.Stacktraceofthread:sun.misc.Unsafe.park(NativeMethod)java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)java.util.concurrent.locks.AbstractQueuedSynchronizerConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.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)
2021-12-06 15:40:48.207 WARN 12216 — [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.beat.sender] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)

2021-12-06 15:40:48.207 WARN 12216 — [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.failover] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
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)

2021-12-06 15:40:48.208 WARN 12216 — [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.push.receiver] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
2021-12-06 15:40:48.219 INFO 12216 — [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2021-12-06 15:40:48.224 ERROR 12216 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

com.alibaba.csp.ahas.sentinel.SentinelAnnotationAutoConfiguration.sentinelResourceAspect(SentinelAnnotationAutoConfiguration.java:44)

The following method did not exist:

com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect.<init>(Lcom/alibaba/csp/sentinel/annotation/aspectj/SentinelAnnotationGlobalFallback;)V

The method’s class, com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect, is available from the following locations:

jar:file:/G:/gradle-repository/com/alibaba/csp/sentinel-annotation-aspectj/1.5.2/sentinel-annotation-aspectj-1.5.2.jar!/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.class
jar:file:/G:/gradle-repository/com/alibaba/csp/ahas-sentinel-client/1.10.1/ahas-sentinel-client-1.10.1.jar!/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.class

It was loaded from the following location:

file:/G:/gradle-repository/com/alibaba/csp/sentinel-annotation-aspectj/1.5.2/sentinel-annotation-aspectj-1.5.2.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect

正在回答 回答被采纳积分+3

1回答

大目 2021-12-08 11:39:03

问题的原因:

sentinel-annotation-aspectj 和 ahas-sentinel-client 这两个jar包中都存在SentinelResourceAspect这个类

参考Ahas文档:https://help.aliyun.com/document_detail/110599.htm

在新版本的Ahas中,可以直接把<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> 删除试试。

0 回复 有任何疑惑可以回复我~
  • 谢谢老师,已解决,当初有这个删除依赖困扰是因为担心sentinel整合restTemplate问题,测试发现整合了AHAS不用再去restTemplate使用@SentinelRestTemplate整合了。
    回复 有任何疑惑可以回复我~ 2021-12-08 12:38:04
  • 大目 回复 提问者 夏洛爱的不是秋雅 #2
    是的哈
    回复 有任何疑惑可以回复我~ 2021-12-13 16:43:08

相似问题

登录后可查看更多问答,登录/注册

问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信