Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is SpringBoot upgrade from 2.3.0 to 2.5.0 failing to start tomcat with Prometheus exceptions? [duplicate]

Previous SpringBoot upgrades have been painless, but our upgrade to 2.5.0 doesn't start. Here's the sort version of the exception:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Unsatisfied dependency expressed through method 'prometheusMeterRegistry' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'prometheusConfig' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Unsatisfied dependency expressed through method 'prometheusConfig' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'management.metrics.export.prometheus-org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@7c0e2abd]

and the very last exception that seems to be causing this whole mess:

Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@7c0e2abd]
        at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
        at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)
        ... 103 common frames omitted
Caused by: java.lang.NoClassDefFoundError: io/micrometer/prometheus/HistogramFlavor
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3244)
        at java.base/java.lang.Class.getDeclaredMethods(Class.java:2387)
        at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
        ... 105 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.micrometer.prometheus.HistogramFlavor
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:590)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:129)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:523)
        ... 109 common frames omitted

I found this reference: https://github.com/prometheus/client_java/issues/452, and in fact the project includes the dependencies for actuator and micrometer mentioned in that answer. I didn't set this up originally so the interplay between components or how one normally troubleshoots and repairs this kind of thing isn't really clear to me.

like image 533
Dave Brennan Avatar asked Oct 19 '25 14:10

Dave Brennan


1 Answers

From the caused by it looks like Micrometer dependecny is missing or not the correct version, you need to add it to pom.xml of your project. Micrometer is a dimensional-first metrics collection facade whose aim is to allow you to time, count, and gauge your code with a vendor neutral AP.

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-spring-legacy</artifactId>
    <version>1.5.1</version>
</dependency>
like image 75
z atef Avatar answered Oct 21 '25 03:10

z atef



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!