4

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.

Dave Brennan
  • 68
  • 1
  • 8

1 Answers1

2

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>
Dave Brennan
  • 68
  • 1
  • 8
z atef
  • 7,138
  • 3
  • 55
  • 50
  • As mentioned above, it already had micrometer dependency (was at version 1.3.2) and spring-boot-starter-actuator (no version specified). I bumped the version, but same error. – Dave Brennan May 30 '20 at 06:40