version: Finchley.RELEASE
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:646)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:303)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:688)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530)
at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:117)
at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:85)
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getContext(SpringClientFactory.java:118)
at org.springframework.cloud.context.named.NamedContextFactory.getInstance(NamedContextFactory.java:126)
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getInstance(SpringClientFactory.java:108)
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getClientConfig(SpringClientFactory.java:65)
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.getClientConfig(LoadBalancerFeignClient.java:78)
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:62)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:97)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy131.entrust(Unknown Source)
at com.polarisex.dragon.engine.sub.QuoteCallBackImpl.orderCallBack(QuoteCallBackImpl.java:79)
at com.polarisex.dragon.engine.AbstractQuoteProcess.callBack(AbstractQuoteProcess.java:86)
at com.polarisex.dragon.engine.sub.AbstractQuoteProcessImpl.orderCallBack(AbstractQuoteProcessImpl.java:123)
at com.polarisex.dragon.engine.sub.AbstractQuoteProcessImpl.processOrder(AbstractQuoteProcessImpl.java:134)
at com.polarisex.dragon.engine.sub.AbstractQuoteProcessImpl.run(AbstractQuoteProcessImpl.java:42)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:732)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClasses(ConfigurationClassParser.java:711)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:617)
... 28 more
What version of spring boot are you using. Finchley requires 2.0.3
yes, i use spring boot 2.0.3. and java 10.
can you provider me some advise to resolve it~
I don't have any idea why that might happen, except for maybe a corrupt download
I see the exact same issue using Java 10 (OpenJDK 10.0.2@Linux64). I've tried with Spring-Framework 5.0.9.RELEASE and 5.0.10.RELEASE in combination with Spring Boot 2.0.5.RELEASE and Spring Boot Cloud Finchley.SR1.
I got the following stacktrace:
...
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:732)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClasses(ConfigurationClassParser.java:711)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:617)
... 52 common frames omitted
In the meanwhile we have also tried _OpenJDK 11.0.1_ with _Spring Framework 5.1.1_ and _Boot 2.1.0RC1_. With the exact same result.
In the last two weeks we have updated 12 microservices from Java 8 to Java 10, the most of them use a quite similar spring boot architecture stack including _Feign, Ribbon, Hystrix, Eureka_ and _Config-Server_. The issue above occurs in only one of these Microserivces. Actually we have no idea what makes this Microservice different to all the other ones.
We have not claimed support for Java 10 or 11 yet. We are in the process of looking at Java 11 now.
Same here, we we're using OpenJDK 10 and OpenJDK 11.0.1, Spring boot 2.0.3.RELEASE, happens every time when compiled as WAR archive. It works all fine when its runned with bootRun
only with boot 2.1.0 and Greenwich will we support jdk 11.
@micha77dd can you try with Greenwich.M2
Works like a charm, thanx!
I've tried with Docker container FROM openjdk:10-jdk and the following dependency setup:
<spring.version>5.1.0.RELEASE</spring.version>
<spring-cloud-aws.version>2.0.1.RELEASE</spring-cloud-aws.version>
<spring-cloud-commons.version>2.1.0.M2</spring-cloud-commons.version>
<spring-cloud-config.version>2.1.0.M3</spring-cloud-config.version>
<spring-cloud-netflix.version>2.1.0.M3</spring-cloud-netflix.version>
<spring-cloud-openfeign.version>2.1.0.M2</spring-cloud-openfeign.version>
<spring-cloud-security.version>2.1.0.M1</spring-cloud-security.version>
(could not use 'Greenwich.M2/M3' directly for some reasons)
Sorry, I was too fast. As it seams my quick test today was not adequate to see the issue. After running a fully featured test I have to say that issue is still present. So, please reopen.
@micha77dd any chance you can provide us your test?
Unfortunately I've absolutely no idea what is that special at this 碌Service (maybe except that we use dynamically created feign clients here). Anyway, I'll spend a few hours this week to dig a bit deeper. I'll keep you informed about my analysis.
Btw. Stacktrace has been slightly changed now:
Exception thrown in method 'booking' of class [com.xxx.xxxxxxx.xxxxxx.control.BookingMediator]org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:649)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:306)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:246)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:203)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:171)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530)
at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:117)
at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:85)
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getContext(SpringClientFactory.java:118)
at org.springframework.cloud.context.named.NamedContextFactory.getInstance(NamedContextFactory.java:126)
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getInstance(SpringClientFactory.java:108)
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getClientConfig(SpringClientFactory.java:65)
at org.springframework.cloud.openfeign.ribbon.CachingSpringLoadBalancerFactory.create(CachingSpringLoadBalancerFactory.java:58)
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.lbClient(LoadBalancerFeignClient.java:104)
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:63)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:97)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy249.booking(Unknown Source)
at com.xxx.xxxxxxx.xxxxxx.control.BookingMediator.handleBookingByAdapter(BookingMediator.java:135)
at com.xxx.xxxxxxx.xxxxxx.control.BookingMediator.lambda$booking$0(BookingMediator.java:87)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1751)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:952)
at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:926)
at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:327)
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.runWorker(ForkJoinPool.java:1603)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:735)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClasses(ConfigurationClassParser.java:714)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:620)
... 36 common frames omitted
Hey, I am having the exact same issue:
Failed to process import candidates for configuration class [org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
This does not seem to happen locally so it is pretty difficult to reproduce. And this also only happens on one particular microservice despite numerous others having an identical setup.
I am using Spring Boot 2.0.4.RELEASE and openJDK 9.
My issue was fixed in the end. It only happened at runtime in a separate thread that wasn't managed by Spring Boot. The fix turned out to be this config in application.yml:
ribbon:
eager-load:
enabled: true
clients: ... comma-separated feign clients...
It seems when a spring-cloud configured feign client is initialized in another thread spring-cloud has some issues with resolving the paths to classes.
The good news is, that we've finally solved our issues. Now we use openJDK 11 and have upgraded all dependency libraries to latest versions (incl. Spring-Framework 5.1.3, Spring Boot 2.1.1 and Spring Cloud Greenwich M3). In parallel we also have refactored our service a bit and use different boundaries for async-jobs and have skipped all @RefreshScope-beans. Finally, we don't see any issue.
The bad news is that we were not able to isolate one specific root cause (since things have changed in parallel and rolling back step by step to find out the cause is not an option in our project schedule, sorry)
@micha77dd so you no longer see the exception?
Right, I don't see the exception anymore since we have updated all stuff as described above.
@manulsoftware are you still seeing an issue?
@manulsoftware are you still seeing an issue?
As I mentioned in the previous post, after adding the ribbon config to load feign clients eagerly the issue went away. If I remove the config it comes back. It only happens when a feign client is initialized in a different thread.
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
I have the same issue. Updating Spring Cloud to Greenwich.M2 does not help.
Spring Boot: 2.1.1.RELEASE
Spring Security: 5.1.2.RELEASE
JDK: openjdk 11 2018-09-25
It happens when I try to start application with:
mvn spring-boot:run
does not happen when application is started from IntelliJ Idea
Still waiting for a project to recreate the issue
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.
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.
I have the same issue. Updating Spring Cloud to Greenwich.RC2 does not help.
Spring Boot: 2.1.1.RELEASE
JDK: openjdk 11 2018-10-16 LTS
@dragontree101
Still waiting for a project to recreate the issue
I was able to replicate this issue in separate project. This project need service registry
./gradlew bootRun doesnt have this issue
but
./gradlew bootJar
and
running java -jar build/libs/feign-0.0.1-SNAPSHOT.jar
results in this problem when you invoke following url http://localhost:8080/hi
Environment
OpenJDK 11.0.2
Spring Boot: 2.1.2.RELEASE
Greenwich.RELEASE
While I agree it replicates it I'm not sure even where to begin looking. @dsyer or @wilkinsona or @philwebb have any of you seen anything like this before?
On the face of it, it looks like a bug in the fat jar support. If you can give me an idiot's guide to setting things up so the sample will work, I can take a look.
I couldn't get the sample to run either. Is this just with a specific version of Java? Can you paste in the stacktrace from when the sample fails?
stacktrace at top of issue.
I reproduced it with this command
java -jar build/libs/feign-0.0.1-SNAPSHOT.jar --eureka.client.enabled=false
then visiting the url listed here https://github.com/spring-cloud/spring-cloud-netflix/issues/3101#issuecomment-463382093
The error does not happen with java 8
./gradlew clean build
was all it took for me to build
We had similar issues in Spring Cloud Function - @olegz would know the details. Something to do with a trailing "/" in jar:... URLs.
@spencergibb You don't get:
Caused by: java.net.UnknownHostException: service-registry
at java.net.InetAddress.getAllByName0(InetAddress.java:1280) ~[na:1.8.0_144]
at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[na:1.8.0_144]
at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[na:1.8.0_144]
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:263) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar!/:4.5.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar!/:4.5.6]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
... 42 common frames omitted
@philwebb you won't see that one if you disable the service discovery (like the the example above): eureka.client.enabled=false. You will still get an exception when you hit the /hi endpoint because there is no service discovery and it is needed at that point. But the nasty Java 11 exception is different - it happens when the Feign client causes a child ApplicationContext to be created lazily.
@philwebb yes this is happening at least on java 11 and you run the following to run
./gradlew clean build
java -jar build/libs/feign-0.0.1-SNAPSHOT.jar --eureka.client.enabled=false
Thanks. Here's the stacktrace again from the sample:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:599) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:302) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:120) ~[spring-cloud-context-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:88) ~[spring-cloud-context-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getContext(SpringClientFactory.java:118) ~[spring-cloud-netflix-ribbon-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.context.named.NamedContextFactory.getInstance(NamedContextFactory.java:129) ~[spring-cloud-context-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getInstance(SpringClientFactory.java:108) ~[spring-cloud-netflix-ribbon-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getClientConfig(SpringClientFactory.java:65) ~[spring-cloud-netflix-ribbon-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.getClientConfig(LoadBalancerFeignClient.java:80) ~[spring-cloud-openfeign-core-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:64) ~[spring-cloud-openfeign-core-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at org.springframework.cloud.sleuth.instrument.web.client.feign.TraceLoadBalancerFeignClient.execute(TraceLoadBalancerFeignClient.java:70) ~[spring-cloud-sleuth-core-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:108) ~[feign-core-10.1.0.jar!/:na]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78) ~[feign-core-10.1.0.jar!/:na]
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) ~[feign-core-10.1.0.jar!/:na]
at com.sun.proxy.$Proxy91.submit(Unknown Source) ~[na:na]
at com.example.feign.TestREst.lambda$get$0(TestREst.java:26) ~[classes!/:na]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728) ~[na:na]
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) ~[na:na]
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177) ~[na:na]
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[spring-core-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51) ~[spring-core-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123) ~[spring-core-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[spring-core-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:685) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClasses(ConfigurationClassParser.java:664) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:570) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
... 31 common frames omitted
Interestingly the ClassPathResource is using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 and not the LaunchedURLClassLoader that supports fat jars. I'm guessing that org.springframework.cloud.netflix.ribbon.SpringClientFactory is creating the ApplicationContext and Thread.currentThread().getContextClassLoader() is different.
Even though it's using a different classloader, I thought our URL handler would still deal with that. Perhaps the problem is that in Java 8 the application classloader is a jdk.internal.loader.BuiltinClassLoader and not a java.net.URLClassLoader? When remote debugging, it doesn't seem to trigger our custom URL handler.
I think the URL handler is a red herring. When the ClassLoader is wrong, EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.class isn't on the class path of the ClassLoader that tries to load it so it's correct that it fails to load.
When SpringClientFactory creates a context, it's assuming that the thread context class loader will be the class loader that should be used by the child context. That holds true on Java 8 but does not hold true on Java 11. When running on Java 8, the TCCL is a TomcatEmbeddedWebappClassLoader. When running on Java 11, the TCCL is a ClassLoaders$AppClassLoader. The thread in both cases is a worker thread in a fork join pool. This looks like https://bugs.openjdk.java.net/browse/JDK-8172726 to me with the code relying on a bug that's been fixed in Java 9.
I think the child context should be explicitly configured to use the ClassLoader from its parent:
if (this.parent != null) {
// Uses Environment from parent as well as beans
context.setParent(this.parent);
context.setClassLoader(this.parent.getClassLoader());
}
This appears to fix the problem in my local testing.
Another quick fix i tested is to include an executor
CompletableFuture.runAsync(()->{},executor);
This is just a temporary workaround
Thanks @wilkinsona for the fix!
Most helpful comment
I think the URL handler is a red herring. When the
ClassLoaderis wrong,EnableConfigurationPropertiesImportSelector$ConfigurationPropertiesBeanRegistrar.classisn't on the class path of theClassLoaderthat tries to load it so it's correct that it fails to load.When
SpringClientFactorycreates a context, it's assuming that the thread context class loader will be the class loader that should be used by the child context. That holds true on Java 8 but does not hold true on Java 11. When running on Java 8, the TCCL is aTomcatEmbeddedWebappClassLoader. When running on Java 11, the TCCL is aClassLoaders$AppClassLoader. The thread in both cases is a worker thread in a fork join pool. This looks like https://bugs.openjdk.java.net/browse/JDK-8172726 to me with the code relying on a bug that's been fixed in Java 9.I think the child context should be explicitly configured to use the
ClassLoaderfrom its parent:This appears to fix the problem in my local testing.