Spring Boot 2 Tomcat metrics
What's inside this article
⌄
- Spring Boot Tomcat class not found metrics
- Spring Boot 2 embedded Tomcat metrics
- Spring Boot metrics Tomcat error
- Spring actuator Tomcat class missing
Full text exception text:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatMetricsBinder' defined in class path resource [io/micrometer/spring/autoconfigure/web/tomcat/TomcatMetricsAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [io.micrometer.spring.web.tomcat.TomcatMetricsBinder] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@7adf9f5f]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)
...
Caused by: java.lang.IllegalStateException: Failed to introspect Class [io.micrometer.spring.web.tomcat.TomcatMetricsBinder] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@7adf9f5f]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
...
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer
at java.lang.Class.getDeclaredMethods0(Native Method)
...
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
...
Most likely, this error occurs due to the old metrics that came from Spring Boot 1 used together with Spring Boot 2.
If you need a hotfix, then as a workaround: you can disable one of the metrics modules in this way: find the place in your application where you use the @EnableAutoConfiguration annotation, and add:
@EnableAutoConfiguration(exclude = {
TomcatMetricsAutoConfiguration.class
})