spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.22k stars 786 forks source link

java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnPropertyCondition] #740

Closed TaotieLin closed 2 years ago

TaotieLin commented 2 years ago

Describe the bug spring-boot 2.5.8 spring-cloud 2020.0.4 spring-cloud-alibaba 2021.1 openFeign 3.0.4

**error stack***

java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnPropertyCondition]
    at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334)
    at org.springframework.context.annotation.ConditionEvaluator.getCondition(ConditionEvaluator.java:124)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:96)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:88)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:71)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.doRegisterBean(AnnotatedBeanDefinitionReader.java:254)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:147)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:137)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.register(AnnotationConfigApplicationContext.java:168)
    at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:122)
    at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:101)
    at org.springframework.cloud.context.named.NamedContextFactory.getInstances(NamedContextFactory.java:181)
    at org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient.execute(FeignBlockingLoadBalancerClient.java:85)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
    at com.alibaba.cloud.sentinel.feign.SentinelInvocationHandler.invoke(SentinelInvocationHandler.java:109)
    at com.sun.proxy.$Proxy200.add(Unknown Source)
    at com.zyy.terminal.service.bsns.TerminalCardBsns.importSingleCard(TerminalCardBsns.java:169)
    at com.zyy.terminal.service.bsns.TerminalCardBsns.lambda$cardImport$0(TerminalCardBsns.java:115)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
    at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

I was calling other services through openFeign in an asynchronous parallel task, and this exception occurred on some of the requests. The first request usually doesn't. Is this a parallel call problem? Thank you for all your help.

OlgaMaciaszek commented 2 years ago

Hello @TaotieLin , 2020.0.4 is no longer supported. Please verify against a supported version (Spring Cloud 2021.0.3 + Spring Boot 2.6.8). If the problem persists, please provide a minimal, complete, verifiable example that reproduces the issue.

TaotieLin commented 2 years ago

@OlgaMaciaszek Thank you very much. I'll try again later.

OlgaMaciaszek commented 2 years ago

Ok. Let us know.

spring-cloud-issues commented 2 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 2 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Bannou commented 2 years ago

Hello, I am facing the same issue as previously described by @TaotieLin

Describe the bug spring-boot 2.7.3 spring-cloud 2021.0.4

Stacktrace

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientConfiguration]; nested exception is java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnPropertyCondition]
                at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:189)
                at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
                at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)
                at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
                at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
                at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
                at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:155)
                at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:108)
                at org.springframework.cloud.context.named.NamedContextFactory.getInstance(NamedContextFactory.java:164)
                at org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory.getInstance(LoadBalancerClientFactory.java:78)
                at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.choose(BlockingLoadBalancerClient.java:171)
                at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.choose(BlockingLoadBalancerClient.java:166)
                at com.xyz.community.connector.LoadBalancedConnectionInfoProvider.uri(LoadBalancedConnectionInfoProvider.java:19)
                at com.xyz.abc.domain.rpc.client.GnpMyClient.call(GnpMyClient.java:30)
                at com.xyz.abc.domain.rpc.client.MetricsMyClient.lambda$call$2(MetricsMyClient.java:42)
                at io.micrometer.core.instrument.AbstractTimer.record(AbstractTimer.java:159)
                at com.xyz.abc.domain.rpc.client.MetricsMyClient.call(MetricsMyClient.java:42)
                at com.xyz.abc.domain.rpc.client.LoggableMyClient.call(LoggableMyClient.java:31)
                at com.xyz.abc.domain.rpc.MyClient.call(MyClient.java:11)
                at com.xyz.abc.subdomain.adapter.bcd.BcdClient.fetchData(BcdClient.java:43)
                at com.xyz.abc.subdomain.adapter.bcd.BcdAdapter.lambda$fetchData$5(BcdAdapter.java:74)
                at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
                at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
                at java.base/java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:442)
                at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
                at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
                at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
                at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
                at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
                at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
                at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
                at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
                at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnPropertyCondition]
                at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334)
                at org.springframework.context.annotation.ConditionEvaluator.getCondition(ConditionEvaluator.java:124)
                at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:96)
                at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:226)
                at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207)
                at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175)
                ... 33 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.condition.OnPropertyCondition
                at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
                at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
                at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
                at java.base/java.lang.Class.forName0(Native Method)
                at java.base/java.lang.Class.forName(Class.java:398)
                at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
                at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324)

I was calling other services through openFeign in a synchronous parallel task, and this exception occurred on some of the requests.

This happens from time a time, not in regular way.

Thank you for your help.

HJK181 commented 2 years ago

Same for me on spring-boot.version: 2.7.2 spring-cloud.version: 2021.0.3 spring-cloud-starter-openfeign: 3.1.3

liuxiong21 commented 2 years ago

I also facing the same issue as previously described by @TaotieLin spring-boot.version: 2.6.3 spring-cloud.version: 2021.0.1 spring-cloud-starter-openfeign: 3.1.1

OlgaMaciaszek commented 2 years ago

@liuxiong21 @HJK181 @Bannou Thanks for your feedback. Reopening the issue. Please provide a minimal, complete, verifiable example that reproduces the issue if you would like us to take a closer look at it.

HJK181 commented 2 years ago

Hi @OlgaMaciaszek isn't the example provided here sufficient? I thought the issues are related.

OlgaMaciaszek commented 2 years ago

Thanks, @HJK181, you're right. In this case, this is a duplicate. Closing in favour of gh-475.

songxiaoxiao commented 1 year ago

java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnBeanCondition]\n\tat org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334) ~[spring-core-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.ConditionEvaluator.getCondition(ConditionEvaluator.java:124) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:96) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:88) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:71) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.AnnotatedBeanDefinitionReader.doRegisterBean(AnnotatedBeanDefinitionReader.java:254) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:147) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:137) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.context.annotation.AnnotationConfigApplicationContext.register(AnnotationConfigApplicationContext.java:168) ~[spring-context-5.3.4.jar!/:5.3.4]\n\tat org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:118) ~[spring-cloud-context-3.0.2.jar!/:3.0.2]\n\tat org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:101) ~[spring-cloud-context-3.0.2.jar!/:3.0.2]\n\tat org.springframework.cloud.context.named.NamedContextFactory.getInstances(NamedContextFactory.java:181) ~[spring-cloud-context-3.0.2.jar!/:3.0.2]\n\tat org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.lambda$execute$2(RetryableFeignBlockingLoadBalancerClient.java:108) ~[spring-cloud-openfeign-core-3.0.2.jar!/:3.0.2]\n\tat org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:329) ~[spring-retry-1.3.1.jar!/:na]\n\tat org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:225) ~[spring-retry-1.3.1.jar!/:na]\n\tat org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.execute(RetryableFeignBlockingLoadBalancerClient.java:103) ~[spring-cloud-openfeign-core-3.0.2.jar!/:3.0.2]\n\tat org.springframework.cloud.sleuth.instrument.web.client.feign.TraceRetryableFeignBlockingLoadBalancerClient.execute(TraceRetryableFeignBlockingLoadBalancerClient.java:79) ~[spring-cloud-sleuth-instrumentation-3.0.2.jar!/:3.0.2]\n\tat feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119) ~[feign-core-10.10.1.jar!/:na]\n\tat feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89) ~[feign-core-10.10.1.jar!/:na]\n\tat feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) ~[feign-core-10.10.1.jar!/:na]\n\tat com.sun.proxy.$Proxy375.accountBalance(Unknown Source) ~[na:na]\n\tat jdk.internal.reflect.GeneratedMethodAccessor1194.invoke(Unknown Source) ~[na:na]\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]\n\tat org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.4.jar!/:5.3.4]\n\tat com.sun.proxy.$Proxy376.accountBalance(Unknown Source) ~[na:na]\n\tat cn.sino.cb.cmp.wallet.service.integrate.WalletWithdrawIntegrate.accountBalance(WalletWithdrawIntegrate.java:109) ~[cb-cmp-wallet-client-2.68.3-SNAPSHOT.jar!/:na]\n\tat cn.sino.cb.cm.portal.service.impl.WalletAccountServiceImpl.lambda$accountBalance$0(WalletAccountServiceImpl.java:78) ~[classes!/:na]\n\tat java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) ~[na:na]\n\tat java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728) ~[na:na]\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[na:na]\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) ~[na:na]\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) ~[na:na]\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) ~[na:na]\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) ~[na:na]\nCaused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.condition.OnBeanCondition\n\tat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]\n\tat java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]\n\tat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]\n\tat java.base/java.lang.Class.forName0(Native Method) ~[na:na]\n\tat java.base/java.lang.Class.forName(Class.java:398) ~[na:na]\n\tat org.springframework.util.ClassUtils.forName(ClassUtils.java:284) ~[spring-core-5.3.4.jar!/:5.3.4]\n\tat org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324) ~[spring-core-5.3.4.jar!/:5.3.4]\n\t... 43 common frames omitted\n