Skip to content

IllegalArgumentException, Could not find class error #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cemthecebi opened this issue Sep 27, 2022 · 7 comments
Closed

IllegalArgumentException, Could not find class error #771

cemthecebi opened this issue Sep 27, 2022 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cemthecebi
Copy link

cemthecebi commented Sep 27, 2022

I'm getting an error from StreamBridge when trying to send a message to a specific Kafka topic. Funny thing is that I only get this error sometimes. When I trigger the service manually it does not give any errors. I stuck with this error for a while

java.version = 17
org.springframework.boot = 2.6.4
spring-cloud.version = 2021.0.1
spring-cloud-starter-stream-kafka = 3.2.4

Code :

@Slf4j
@Service
@RequiredArgsConstructor
public class UpdateEventAdapter implements UpdateEventPort {

    private final StreamBridge streamBridge;

    @Async
    @Override
    public void instrumentUpdated(InstrumentUpdatedEvent instrumentUpdatedEvent) {
        streamBridge.send(INSTRUMENT_UPDATED_PRODUCER, KafkaMessageBuilder.build(instrumentUpdatedEvent, instrumentUpdatedEvent.getUid()));
    }
}

Trace:

va.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnBeanCondition] at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[na:na] at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[na:na] at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) ~[na:na] at util.TokenAwareRunnable.run(TokenAwareRunnable.java:28) ~[na:na] at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395) ~[na:na] at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[na:na] at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[na:na] at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[na:na] at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[na:na] at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[na:na] Caused by: java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnBeanCondition] at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334) ~[spring-core-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.ConditionEvaluator.getCondition(ConditionEvaluator.java:124) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:96) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:88) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:71) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.doRegisterBean(AnnotatedBeanDefinitionReader.java:254) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:147) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:137) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.context.annotation.AnnotationConfigApplicationContext.register(AnnotationConfigApplicationContext.java:168) ~[spring-context-5.3.16.jar!/:5.3.16] at org.springframework.cloud.stream.binder.DefaultBinderFactory.initializeBinderContextSimple(DefaultBinderFactory.java:410) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.binder.DefaultBinderFactory.getBinderInstance(DefaultBinderFactory.java:265) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.binder.DefaultBinderFactory.doGetBinder(DefaultBinderFactory.java:223) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.binder.DefaultBinderFactory.getBinder(DefaultBinderFactory.java:151) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.binding.BindingService.getBinder(BindingService.java:389) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.binding.BindingService.bindProducer(BindingService.java:273) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.function.StreamBridge.resolveDestination(StreamBridge.java:282) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:210) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:164) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:144) ~[spring-cloud-stream-3.2.2.jar!/:3.2.2] at com.getmidas.instrument.api.adapter.kafka.InstrumentUpdateEventAdapter.instrumentUpdated(InstrumentUpdateEventAdapter.java:24) ~[classes!/:0.0.1-SNAPSHOT] at com.getmidas.instrument.api.domain.service.StockService.sendInstrumentEvent(StockService.java:194) ~[classes!/:0.0.1-SNAPSHOT] at com.getmidas.instrument.api.domain.service.StockService.update(StockService.java:166) ~[classes!/:0.0.1-SNAPSHOT] at com.getmidas.instrument.api.domain.service.sync.instrument.tr.TrInstrumentSyncHelper.updateStock(TrInstrumentSyncHelper.java:92) ~[classes!/:0.0.1-SNAPSHOT] at com.getmidas.instrument.api.domain.service.sync.instrument.tr.TrInstrumentSyncHelper.syncHelper(TrInstrumentSyncHelper.java:36) ~[classes!/:0.0.1-SNAPSHOT] at com.getmidas.instrument.api.domain.service.sync.instrument.tr.TrInstrumentSyncService.lambda$syncCompletable$5(TrInstrumentSyncService.java:86) ~[classes!/:0.0.1-SNAPSHOT] at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[na:na] ... 7 common frames omitted Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.condition.OnBeanCondition at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na] at java.base/java.lang.Class.forName0(Native Method) ~[na:na] at java.base/java.lang.Class.forName(Class.java:467) ~[na:na] at org.springframework.util.ClassUtils.forName(ClassUtils.java:284) ~[spring-core-5.3.16.jar!/:5.3.16] at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324) ~[spring-core-5.3.16.jar!/:5.3.16]

@olegz
Copy link
Contributor

olegz commented Sep 27, 2022

Without a way to reproduce it there is no error, especially with CNFE on spring boot class which is at the core of everything.
Any chance you can provide a sample that reproduces it?

@cemthecebi
Copy link
Author

cemthecebi commented Sep 28, 2022

I will try to reproduce the error, however when looking at the stack-trace, it is obvious that the ForkJoinWorkerThread in a Docker image built using the Spring Boot Build Image plugin seems to cause this error when trying to lazily initialize. The error seems to be strongly related to the Spring Boot Build Image, since using jib instead, does not cause this error.

The same is true for running the Docker image in certain Kubernetes environments, although not all environments seem to be affected.

Same problem happened with spring boot cloud openfeign, maybe it helps someway
#475

@HJK181
Copy link

HJK181 commented Oct 5, 2022

I'm facing the same problem when my application is running inside Docker. However, running the same code from the IDE works ...

@sobychacko
Copy link

Could you please create a small reproducible app with specific instructions to build and run?

@HJK181
Copy link

HJK181 commented Oct 6, 2022

I've should have been more precise in my explanation, I'm also facing

java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.condition.OnBeanCondition at

but in the context of spring-cloud-openfeign. But what is similar to the issue here is, that the problem does only appear when executing the application inside a Docker container. The same application running in the IDE works fine. The author of that issue provided a sample

@olegz olegz transferred this issue from spring-cloud/spring-cloud-stream Oct 17, 2022
@olegz
Copy link
Contributor

olegz commented Oct 17, 2022

As last user explained this issue only appears with the addition of open feign, hence the transfer of the issue

@OlgaMaciaszek OlgaMaciaszek added bug Something isn't working and removed waiting-for-triage labels Oct 18, 2022
@OlgaMaciaszek OlgaMaciaszek self-assigned this Oct 18, 2022
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2021.0.9 Jul 19, 2023
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2022.0.4 Jul 19, 2023
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2023.0.0-M1 Jul 19, 2023
@OlgaMaciaszek OlgaMaciaszek added this to the 3.1.9 milestone Jul 20, 2023
@OlgaMaciaszek OlgaMaciaszek moved this from In Progress to Done in 2021.0.9 Jul 20, 2023
@OlgaMaciaszek OlgaMaciaszek moved this from In Progress to Done in 2022.0.4 Jul 20, 2023
@OlgaMaciaszek OlgaMaciaszek moved this from In Progress to Done in 2023.0.0-M1 Jul 20, 2023
@OlgaMaciaszek
Copy link
Collaborator

Fixed with spring-cloud/spring-cloud-commons#1256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Status: Done
Status: Done
Development

No branches or pull requests

6 participants