Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The incompatibility between OpenJDK11 and Spring Cloud Finchley and its solution

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly talks about "the incompatibility between OpenJDK11 and Spring Cloud Finchley and its solutions". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the incompatibility between OpenJDK11 and Spring Cloud Finchley and its solutions.

The environment of this article: OpenJDK 11.0.4jue Spring Cloud finchley SR4,Spring Boot 2.0.3

Recently, there is a problem that such a strange error often occurs when feign is called:

2019-10-07 08 ERROR [xxx,e1ba4c7540954aa3871b99c4576d42e3] [24] [XNIO-2 task-286] [xxx:83]: URI: [/ xxx], method: [PUT], 500Exception: class com.netflix.hystrix.exception.HystrixRuntimeException, xxxxx#xxxx (xxx) failed and no fallback available.com.netflix.hystrix.exception.HystrixRuntimeException: xxxxx#xxxx (xxx) failed and no fallback available. At com.netflix.hystrix.AbstractCommand$22.call (AbstractCommand.java:822) ~ [at com.netflix.hystrix.AbstractCommand$22.call (AbstractCommand.java:807) 1.5.18] at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError (OperatorOnErrorResumeNextViaFunction.java:140) ~ [Rxjava Muhl 1.3.8.jarhammer Blade 1.3] .8] omit the useless stack Caused by: 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) ~ [springMutual contextual 5.0.13.RELEASE.jarhammer] at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass (ConfigurationClassParser.java:303) ~ [RELEASE. At org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass (ConfigurationClassParser.java:245) ~ [at org.springframework.context.annotation.ConfigurationClassParser.parse 5.0.13.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.parse (ConfigurationClassParser.java:202) ~ [springlycontextual Release5.0.13.RELEASE] at org.springframework.context .annotation.ConfigurationClassParser.parse (ConfigurationClassParser.java:170) ~ [springmuri contextual 5.0.13.RELEASE.jarmist] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions (ConfigurationClassPostProcessor.java:316) ~ [springlycontextur 5.0.13.RELEASE.parse (spring-context-5.0)] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry (RELEASE) ~ [spring-context-5.0 .13.RELEASE.jar! /: 5.0.13.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors (PostProcessorRegistrationDelegate.java:271) ~ [springlycontextMel 5.0.13.RELEASE.jarbasket] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcessorRegistrationDelegate.java:91) ~ [springlycontextlle 5.0.13.RELEASE.jar] at Org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors (AbstractApplicationContext.java:706) ~ [springmuri contextual 5.0.13.RELEASE.jarring] at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:533) ~ [springlycontextual 5.0.13.RELEASE.jarhammer] at org.springframework.cloud.context.named.NamedContextFactory.createContext (NamedContextFactory.java:117) ~ [ At org.springframework.cloud.context.named.NamedContextFactory.getContext (NamedContextFactory.java:85) ~ [springmuri cloudlue contextlle 2.0.3.RELEASE.jarlise] at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getContext (SpringClientFactory.java:118) ~ [springMurray cloudlycontextlue 2.0.3.RELEASE.jarmist] RELEASE ~ [RELEASE. At org.springframework.cloud.context.named.NamedContextFactory.getInstance (NamedContextFactory.java:126) ~ [springlycloudMurray contextly2.0.3.RELEASE] at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getInstance (SpringClientFactory.java:108) ~ [springMustcloudMuffle NetflixMuribbonly2.0.3.RELEASE. JarmerPlus 2.0.3.RELEASE]

This error is strange, as long as it is recompiled and released, it will not occur again. This is probably a packaging problem, as well as a class loading problem.

On the query github, people in the community say it's a class loading problem (https://github.com/spring-cloud/spring-cloud-netflix/issues/3101#issuecomment-463382093). First of all, for OpenJDK, there used to be a Bug (https://bugs.openjdk.java.net/browse/JDK-8172726): for ParallelStream, we know that the default is to be executed by CommonForkJoinPool with a default size of CPU core minus 1 when JDK starts. In a multi-threaded and multi-class loader environment, this CommonForkJoinPool may have Bug, that is, when Thread.contextClassLoader is called, it returns the Classloader of the first code that uses CommonForkJoinPool, rather than the system root ClassLoader, which will cause the class not to be found.

The community fixed this Bug, but on the next major version, GreenWich, there was no fix for Finchley.

We consider two solutions:

Upgrading to GreenWich is a big change, from Finchley to GreenWich,Bean initialization mechanism, JDBC connection pooling, and so on, which is time-consuming and laborious in the short term.

Reference: https://github.com/spring-cloud/spring-cloud-commons/commit/b38ce54410af8fc62d8ae6fe694b580e509ae73a#diff-8c70f107deac71db815f81fa81d5f947, overwrite source code, modify org.springframework.cloud.context.named.NamedContextFactory:

Protected AnnotationConfigApplicationContext createContext (String name) {AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (); if (this.configurations.containsKey (name)) {for (Class configuration: this.configurations.get (name) .getConfiguration ()) {context.register (configuration) }} for (Map.Entry entry: this.configurations.entrySet ()) {if (entry.getKey (). StartsWith ("default.")) {for (Class configuration: entry.getValue (). GetConfiguration ()) { Context.register (configuration) } context.register (PropertyPlaceholderAutoConfiguration.class, this.defaultConfigType) Context.getEnvironment (). GetPropertySources (). AddFirst (new MapPropertySource (this.propertySourceName, Collections. SingletonMap (this.propertyName, name)); if (this.parent! = null) {/ / Uses Environment from parent as well as beans context.setParent (this.parent); / / add code here, using parent's classloader context.setClassLoader (this.parent.getClassLoader ()) } context.setDisplayName (generateDisplayName (name)); context.refresh (); return context;}

This is also an emergency plan to solve the problem in the short term. Leave enough time to upgrade.

At this point, I believe you have a deeper understanding of the "incompatible problems and solutions between OpenJDK11 and Spring Cloud Finchley". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 239

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report