Tag Archives: feign

Feign exception missing. When an exception occurs in springboot 2.3. X, the message and exception in response are empty

Reason: because boot2.3. X may consider information security issues, the following two values are defaulted to

server:
  error:
    include-message: never
    include-exception: false

The exception is returned

{
  "timestamp": 1632713940269,
  "status": 500,
  "error": "Internal Server Error",
  "message": "",
  "path": "/xxxx"
}

After modification

server:
  error:
    include-message: always
    include-exception: true

The exception is returned

{
  "timestamp": 1632713940269,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "com.xxxx.xxxxException",
  "message": "Illegal access",
  "path": "/xxxxx"
}

Spring cloud consumer feign injection error [How to Solve]

Error Message:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘orderInfoController’: Unsatisfied dependency expressed through field ‘baseFeign’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.sinoeve.ctm.orderconsumer.Feign.BaseFeign’: FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-netflix-ribbon?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE

The interface did not clearly indicate an error, so I had to target the pom configuration file first. As expected, it was a POM configuration problem

 

The error introduced here should correctly be

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

Error reported by feign component of springcloud microservice

Today, when building a microservice with spring cloud, feign was used as the communication component, and an error was reported

java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.openfeign.ribbon.FeignRibbonClientAutoConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@58644d46]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:728) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:670) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:638) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1507) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:421) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:391) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:97) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M3.jar:2.0.0.M3]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M3.jar:2.0.0.M3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M3.jar:2.0.0.M3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M3.jar:2.0.0.M3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M3.jar:2.0.0.M3]
	at com.wugui.spring.cloud.weather.Application.main(Application.java:14) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/springframework/cloud/client/loadbalancer/LoadBalancedRetryFactory
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_31]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2693) ~[na:1.8.0_31]
	at java.lang.Class.getDeclaredMethods(Class.java:1967) ~[na:1.8.0_31]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
	... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_31]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_31]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_31]
	at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_31]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_31]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_31]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_31]
	... 23 common frames omitted

The main reason is that the related class loadbalancedretryfactory cannot be found

Solution:

The springboot version and the corresponding version of springcloud are provided. The original version is:

        springBootVersion = '2.0.0.M3'
        springCloudVersion = 'Finchley.M2'

Replace with:

	springBootVersion = '2.0.0.M3'
	springCloudVersion = 'Finchley.M9'